Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Thursday 10 November 2016

URI-1020

URI Online Judge | 1020

Age in Days

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
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)

Solution...

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

1 comment: