Home > Back-end >  To output is Friday the 13th days in a year
To output is Friday the 13th days in a year

Time:09-19

Since 2016.1.1, this day is Friday, input n year, in this Friday is 13 days of the year, 2016, such as input output 2016 1, multiple sets of input, I the only output between n and 2016 a total of how many days, and the answer is no I don't know where is wrong, you who help me # include
using namespace std;
Int main () {int n, c=0, count=0; While (cin> N) {int year=2016; Int the month=1; Int day=1;
Int weekday=5;
For (int I=2016; i<=n; I++) {
If ((I % 4==0 & amp; & I % 100!=0) | | I %==0 400)
C=c + 366;
The else
C=c + 355; } for(int i=1; i<=c; I++) {day +=1; Weekday +=1; {if (weekday==8) weekday=1; {} switch (month) case 1: case 3: case 5: case 7: case 8: case 10: case 12: the if (day==32) {month=month + 1; Day=1; {} the if (the month==13) year=year + 1; The month=1; } break; Case 2: if ((year % 4==0 & amp; & Year % 100!=0) | | year %==0 400) {if (day==30) {month=month + 1; Day=1; }} else {the if (day==29) {month=month + 1; Day=1; }} to break; Default: if (31) day=={month=month + 1; Day=1; {} the if (the month==13) year=year + 1; The month=1; } break; } the if (day==13 & amp; & Weekday==5) count++; } cout}

CodePudding user response:

Typography moving,

CodePudding user response:

reference 1st floor CHXCHXKKK response:
typesetting format moving,
I just use this software, a good copy, stickup go up in confusion

CodePudding user response:

reference 1st floor CHXCHXKKK response:
typesetting format moving,
# include
using namespace std;
Int main () {
Int n, c=0, count=0;
While (cin> N) {
Int year=2016;
Int the month=1;
Int day=1;
Int weekday=5;
For (int I=2016; i<=n; I++) {
If ((I % 4==0 & amp; & I % 100!=0) | | I %==0 400)
C=c + 366;
The else
C=c + 355;
}
for(int i=1; i<=c; I++) {
Day +=1;
Weekday +=1;
{if (weekday==8)
Weekday=1;
}
The switch (month) {
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12:
If (day==32) {
The month=month + 1;
Day=1;
}
If (the month==13) {
year=year+1;
The month=1;
} break;
Case 2:
If ((year % 4==0 & amp; & Year % 100!=0) | | year %==0 400) {
If (day==30) {
The month=month + 1;
Day=1;
}
}
The else {
If (day==29) {
The month=month + 1;
Day=1;
}
} break;
Default:
If (31) day=={
The month=month + 1;
Day=1;
}
If (the month==13) {
year=year+1;
The month=1;
} break;
}
If (day==13 & amp; & Weekday==5)
count++;
}
Coutcount=0;
c=0;
}
return 0;
}

CodePudding user response:

reference 1st floor CHXCHXKKK response:
typesetting format moving,
who helped me
  • Related