Xiao Lin's parents is a bit old, memory is a bit poor, at the same time they are devout christians, every Sunday they all want to go to church to pray, and party a day they asked xiao Lin the most question is "what day is it today?" , xiao Lin sometimes answer not to come out, please write a program to help xiao Lin to solve this problem, so that he can always correct answer parents' problems,
Input format:
Year/month/day, there are multiple sets of test data, ends with a zero input,
The output format:
What day
Input the sample:
1/1/1
2017/12/11
2017/1/1
0
The output sample:
Here is given the corresponding output, for example:
On Monday,
On Monday,
Sunday
CodePudding user response:
Q input reply
Int n=0, y=0, r=0.
Char f;
While (1)
{
Cin> N> F> Y> F> r;
if(! N | |! Y | |! R) break;
Other processing statement
}
CodePudding user response:
Reference:# include & lt; Stdio. H>
Int get_Week (int y, int m, int d);
Int main ()
{
Int year=0, the month=0, day=0;
Char week [] [8]={" Monday ", "Tuesday", "on Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
While (the scanf (" % d/% d % d ", & amp; Year, & amp; The month, & amp; Day)==3 & amp; & Year!=0 & amp; & The month!=0 & amp; & day!=0) {
Printf (" % s \ n ", week [get_Week (year, month, day)]);
}
return 0;
}
Int get_Week (int y, int m, int d)
{
Int week=0;
If (m==1 | | m==2)
{
M +=12;
Y -;
}
Week=(d + 2 * m + 3 * (m + 1)/5 + y + 100 + 4 - y/y/y/400) % 7;
Return the week;
}