--> Age in Days (beeCrowd- 1020) URI 1020 Solution C, Python | Alpha Codist

Search This Blog

Age in Days (beeCrowd- 1020) URI 1020 Solution C, Python

Age in Days beeCrowd 1020 URI Solution C, Python alpha codist years days monts converting coding programming input modulus % / mes(es) dia(s) ano(s)

Age in Days

Age in Days beeCrowd 1020 URI Solution C, Python alpha codist years days monts converting coding programming input modulus % / mes(es) dia(s) ano(s)


You have to read an integer value. This value is in seconds. All you have to do is convert it to hour:minute: second format.

The formula is:

  1. Take input. 
  2. Convert the days to years.
  3. Then subtract the number of days you converted. (days % 365)
  4. Now convert the remaining to months.
  5. At last, get the remaining days.
  6. Print as said.


The solution in C:


#include <stdio.h>

int main() {
 
    int days,months,years;
    scanf("%d",&days);
    years =  days/365;
    days =  days % 365;
    months =  days/30;
    days =  days % 365 % 30;
    printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n",years,months,days);
 
    return 0;
}


The solution in Python:


days = int(input())
years =  days/365;
days =  days % 365;
months =  days/30;
days =  days % 365 % 30;
print("%d ano(s)\n%d mes(es)\n%d dia(s)" % (years,months,days));

COMMENTS

Name

beeCrowd,11,C,10,Computer,9,Downloads,3,HTML,1,My Creation,2,Python,24,Python-Soft,1,Shooting,2,
ltr
item
Alpha Codist: Age in Days (beeCrowd- 1020) URI 1020 Solution C, Python
Age in Days (beeCrowd- 1020) URI 1020 Solution C, Python
Age in Days beeCrowd 1020 URI Solution C, Python alpha codist years days monts converting coding programming input modulus % / mes(es) dia(s) ano(s)
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMO2PbbRpZwdvTDjUM4f2EJSMYPLWSTl1VoAAnI7Sez9MJ5NcK2e4wBr5dIuSvRZLxGJjEiBz14DcccqPt-O3_9bCn0aD6Y0f3rHw73W_Fe04iDUfvo6E0Nz0LHvjxP_w1h6OgXO9ub73HGifTlS_VdbgpmTXpjWgOLbmhADPaA5Qu5ypNuWP7qHppXQ/w640-h422/1020.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMO2PbbRpZwdvTDjUM4f2EJSMYPLWSTl1VoAAnI7Sez9MJ5NcK2e4wBr5dIuSvRZLxGJjEiBz14DcccqPt-O3_9bCn0aD6Y0f3rHw73W_Fe04iDUfvo6E0Nz0LHvjxP_w1h6OgXO9ub73HGifTlS_VdbgpmTXpjWgOLbmhADPaA5Qu5ypNuWP7qHppXQ/s72-w640-c-h422/1020.png
Alpha Codist
https://alphacodist.blogspot.com/2022/12/blog-post.html
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/2022/12/blog-post.html
true
7547834254111195316
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 Table of Content