Home > Back-end >  C language implementation unlucky date
C language implementation unlucky date

Time:10-01

On Friday the 13th of each month is for unlucky day, January 1, 1990 known for Monday, C language program design, user input, output the year date of bad luck

CodePudding user response:

Input format is not clear

CodePudding user response:

Tell me about the input format

CodePudding user response:

# include & lt; Iostream>
using namespace std;

Int getWeekDay (int y, int m, int d) {
If (m==1 | | m==2) {
M +=12;
Y -;
}
Return (d + 2 * m + 3 * (m + 1)/5 + y + 4 - y/100 + y/y/400) % 7;
}

Int main () {
Int year;
While (cin & gt;> Year) {
Int I, flag=1;
For (I=1; I & lt;=12; I++) {
If (getWeekDay (year, I, 13)==4) {
If (flag==1)
Flag=0;
The else
Cout & lt; <"';
Cout & lt; }
}
Cout & lt; }
return 0;
}
Is that so?
  • Related