A set of correct is 16. Output by 15
Another group of correct is 13754, the output 13755
For bosses to help have a look, thank thank!!
#include
using namespace std;
Int main ()
{
31,28,31,30,31,30,31,31,30,31,30,31 int mon [12]={};
Int year1 year2, mon1 mon2, day1, day2, I, m1=0, n1=0, n2=0, sum=0, t1=0, t2=0, t;
Cin> Year1 & gt;> Mon1 & gt;> Day1.
Cin> Year2 & gt;> Mon2 & gt;> Day2.
for(i=0; i<12. I++)
{
If (mon1==I + 1)
M1=mon [I] - day1.
}
For (I=mon1; i<12. I++)
{
N1 +=mon [I];
}
for(i=0; i
N2 +=mon [I];
}
If ((year1%4==0 | | year1%400==0) & amp; & (year1%100!=0))
{if (mon1 & lt;
=2)If (day1. 29)={t1 + +; }}
If ((year2%4==0 | | year2%400==0) & amp; & (year2%100!=0))
{if (mon2 & gt; 2) t2 + +; }
For (I=year1 + 1, t=0; i
If ((I % 4==0 | | I % 400==0) & amp; & (I % 100!=0)) {t++; }
}
Sum=m1 + n1 + n2 + (year2 - year1-1) * 365 + day2 + t + t1, t2;
cout
}
CodePudding user response:
To determine the leap year is wrong, should is year1%4==0 & amp; & Year1%100! 400==0 | | year1 %=0CodePudding user response:
Fyi:# include & lt; Afxdisp. H>
# include & lt; stdio.h>
# include & lt; Stdlib. H>
Int main (int arg c, TCHAR * argv []) {
COleDateTime t;
COleDateTimeSpan ts;
Cstrings s, FMT;
Int nYear.
Int nMonth;
Int nDay;
Int nHour;
Int nMin;
Int nSec.
Int lDays;
Int nHours.
Int nMins;
Int nSecs;
Int I, N;
//initialize the MFC and the print and the error on failure
if (! AfxWinInit (: : GetModuleHandle (NULL), NULL, : : GetCommandLine (), 0)) {
Printf (" Fatal Error: MFC initialization failed \ n ");
return 1;
}
If (argc<13) {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 2;
}
If (stricmp (argv [12], "SQL")==0) FMT="% % Y - m - H: % d % % m: % S".
Else if (stricmp (argv [12], "YYYY")==0) FMT="% % m % d % Y H % m % S".
Else if (stricmp (argv [12], "YY")==0) FMT="% % m % d % y H % m % S".
The else {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 3;
}
NYear=atoi (argv [1]);
NMonth=atoi (argv [2]);
NDay=atoi (argv [3]);
NHour=atoi (argv [4]);
NMin=atoi (argv [5]);
NSec=atoi (argv [6]);
LDays=atoi (argv [7]);
NHours=atoi (argv [8]);
NMins=atoi (argv [9]);
NSecs=atoi (argv [10]);
N=atoi (argv [11]);
If (N<=0) {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 4;
}
T=COleDateTime (nYear, nMonth nDay, nHour, nMin, nSec);
Ts=COleDateTimeSpan (lDays nHours, nMins, nSecs);
For (I=1; i<=N; I++) {
S=t.F ormat (FMT);
08 printf (" % d % s \ n ", I, s);
T=t + ts;
}
return 0;
}
CodePudding user response:
# include & lt; stdio.h>//get the Gregorian calendar year the number of days
During the int year_alldays (int)
{
If ((year % 4==0 & amp; & Year % 100!=0) | | year % 400==0) return 366; The else return 365;
}
//to get at the beginning of the Gregorian calendar to the number of days a month
During the int year_sumday (int, int the month)
{
int sum=0;
31,29,31,30,31,30,31,31,30,31,30,31 int rui [12]={};
Int ping [12]={31,28,31,30,31,30,31,31,30,31,30,31};
Int ruiflag=0;
If ((year % 4==0 & amp; & Year % 100!=0) | | year % 400==0) ruiflag=1;
For (int index=0; Index
If (ruiflag==1) sum +=rui [index]; The else sum +=ping [index];
}
return sum;
}
//to get from the Gregorian calendar in 1800 January 25 solstice current date the total number of days of
During the int get_g_alldays (int, int the month, int day
{
Int I=1800 days=- 24;
While (i
Days +=year_alldays (I);
i++;
}
Int days2=year_sumday (year, month);
The return days + days2 + day;
}
Int main (void)
{
Int year1 year2, month1, month2, day1, day2;
Printf (" please enter the start date input format - dd yyyy - mm: \ n ");
The scanf (" % d % d - % d ", & amp; Year1, & amp; Month1, & amp; Day1);
Printf (" please enter an end date input format - dd yyyy - mm: \ n ");
The scanf (" % d % d - % d ", & amp; Year2, & amp; Month2, & amp; Day2);
Int days1=get_g_alldays (year1, month1, day1);
Int days2=get_g_alldays (year2, month2, day2);
Int sout=0;
If (days1 & gt;=days2) sout=days1 - days2; The else sout=days2 - days1;
Printf (" % from % 2 d, 4 d % % 2 d to 4 d years on % 2 d % 2 d % between 8 d days. \ n ", year1, month1, day1, year2, month2, day2, sout);
return 0;
}
CodePudding user response:
To determine the leap year is wrong, should is year1%4==0 & amp; & Year1%100! 400 1%=0 | |==0CodePudding user response:
To join https://ask.csdn.net/questions/1063222#answer_1261149