Enter the day of the month, the days of the year when calculated

Source: Internet
Author: User

#include"stdio.h"voidMain () {/*year month months month1 backup month Day Day1 backup total number of days used to receive the number of days in the month, D1 the number of days that the month was backed up. s calculates the total number of days of the month before the current month sum of days sum*/   intyear,month,month1,day,day1,d1,sum=0, s=0; printf ("Please enter the year:"); scanf ("%d",&Year );      Fflush (stdin);  Do{printf ("Please enter the month:"); scanf ("%d",&month);   Fflush (stdin); if(month<1|| Month> A)//prompt for incorrect input{printf ("you entered the error \ n"); }         } while(month<1|| Month> A);//determine if the input month is incorrect//1 3 5 7 8//4 6 9 eachMonth1=month;//number of months to backupmonth--;//month--: minus the current month total, calculated, the total number of days in the month is not counted, (January 28, January total days 31 days do not count in)    for(; month>=1; month--)   {     if(month==1|| month==3|| month==5|| month==7|| month==8|| month==Ten|| month== A) { Day= to; }Else            if(month==4|| month==6|| month==9|| month== One) { Day= -; }Else         if(month==2)     {           if(year%4==0&&year% -==0|| year% -==0) { Day= -; }Else{ Day= in; }} s=s+Day ; }d1=Day ;  Do{printf ("Please enter the day:"); scanf ("%d",&Day );           Fflush (stdin); Day1=Day ; if(day1<1|| Day1>d1) printf ("you entered the error \ n"); } while(day1<1|| Day1>D1); Sum=day1+s;//Total days Expressionprintf"%d months%d days is %d%d years", month1,day1,year,sum); }

Enter the day of the month, the days of the year when calculated

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.