URI-1020 Solve

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 be 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)
Problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/1020

Solution:

  • [tab]
    • C
      • #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;
        
         }
    • C++
      • #include <iostream>
        
        using namespace std;
        
        int main()
        {
         int n;
         
         cin >> n;
         
         int a = n / 365;
         int rA = n % 365;
         int rM = rA % 30;
         int m = rA / 30;
         int d = rM % 30;
         
         cout << a << " ano(s)" << endl << m << " mes(es)" << endl << d << " dia(s)" << endl;
         
         return 0;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1020 Solve
URI-1020 Solve
DorHubs
https://dorhubs.blogspot.com/2019/08/uri-1020-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/08/uri-1020-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy