Thursday, May 26, 2016

URI Online Judge Solution || 1020 Age in Days

URI Online Judge | 1020

Age in Days

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer value corresponding to a person's age (in days) and print it in years, months and days, followed by its respective message “ano(s)”, “mes(es)”, “dia(s)”.
Note: only to facilitate the calculation, consider the whole year with 365 days and 30 days every month. In the cases of test there will never a situation that allows 12 months and some days, like 360, 363 or 364. This is just an exercise for the purpose of testing simple mathematical reasoning.

Input

The input file contains 1 integer value.

Output

Print the output, like the following example.
Input SampleOutput Sample
4001 ano(s)
1 mes(es)
5 dia(s)
8002 ano(s)
2 mes(es)
10 dia(s)
300 ano(s)
1 mes(es)
0 dia(s)

URI Online Judge Solution || 1020 Age in Days in C language



#include<stdio.h>
 int main(){
    int y, m, d, n;
    scanf("%d", &n);
 
    y = n / 365;
    m = n % 365 / 30;
    d = n % 365 % 30;
    printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n", y, m, d);
    return 0;
 }




View or download source code of URI 1020 from Dropbox
URI Link


No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.