1#include <iostream>2#include <string>3 using namespacestd;4 intMain () {5cout<<"Please enter a date:"<<Endl;6 intA;7Cin>>A;8 BOOLHehe=false;9 if(99999999<a&&a<10000000)Ten { OneHehe=true; A } - while(hehe) - { thecout<<"the number of date bits entered is not enough or exceeded! Please re-enter:"<<Endl; -Cin>>A; - if(99999999<a&&a<10000000) - { +Hehe=true; - } + Else A { atHehe=false; - } - } - intDay ; -day=a%Ten; - intC; inc=a/Ten%Ten; -day=day+ (c*Ten); toc=a/ -%Ten; + intmonth; -month=a/ +%Ten; theMonth= (month*Ten)+C; *c=a/10000%Ten; $ intYear ;Panax NotoginsengYear=C; -c=a/100000%Ten; theyear=year+ (c*Ten); +c=a/1000000%Ten; Ayear=year+ (c* -); thec=a/10000000%Ten; +year=year+ (c* +); - if(year< +) $ { $cout<<"Enter the year error! "<<Endl; - return 0; - } the - if(month> A)Wuyi { thecout<<"Enter month Error! "<<Endl; - return 0; Wu } - if(day> to) About { $cout<<"Wrong input date! "<<Endl; - return 0; - } - intmax=0; A if((year%4==0&&year% -!=0)|| (year% -==0)) + { thecout<<"your date is a leap year! "<<Endl; - Switch(month) $ { the Case 1: Max=day; Break; the Case 2: max=day+ in; Break; the Case 3: max=day+ to+ in; Break; the Case 4: max=day+ ( to*2)+ in; Break; - Case 5: max=day+ ( to*2)+ in+ -; Break; in Case 6: max=day+ ( to*3)+ in+ -; Break; the Case 7: max=day+ ( to*3)+ in+( -*2); Break; the Case 8: max=day+ ( to*4)+ in+( -*2); Break; About Case 9: max=day+ ( to*5)+ in+( -*2); Break; the Case Ten: max=day+ ( to*5)+ in+( -*3); Break; the Case One: max=day+ ( to*6)+ in+( -*3); Break; the Case A: max=day+ ( to*6)+ in+( -*4); Break; + } - } the ElseBayi { thecout<<"your date is not a leap year! "<<Endl; the Switch(month) - { - Case 1: Max=day; Break; the Case 2: max=day+ -; Break; the Case 3: max=day+ to+ -; Break; the Case 4: max=day+ ( to*2)+ -; Break; the Case 5: max=day+ ( to*2)+ -+ -; Break; - Case 6: max=day+ ( to*3)+ -+ -; Break; the Case 7: max=day+ ( to*3)+ -+( -*2); Break; the Case 8: max=day+ ( to*4)+ -+( -*2); Break; the Case 9: max=day+ ( to*5)+ -+( -*2); Break;94 Case Ten: max=day+ ( to*5)+ -+( -*3); Break; the Case One: max=day+ ( to*6)+ -+( -*3); Break; the Case A: max=day+ ( to*6)+ -+( -*4); Break; the }98 } Aboutcout<<"The date you entered is the first of this year:"<<max<<"days. "<<Endl; -}
Enter a certain day of the year, judging the day is the first of the year?