URI ONLINE JUDGE SOLUTION 1020 - Age in Days

Problem


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.

sample input output


Solution

#include<stdio.h>
int main()
{
    int x,a[3];
    scanf("%d",&x);
    a[0]=x/365;
    x=x%365;
    a[1]=x/30;
    a[2]=x%30;
    printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n",a[0],a[1],a[2]);
    return 0;

}

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula