第一个被板刷的题
取余 依次算在周几
1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<cmath> 7 #include<map> 8 using namespace std; 9 double ll,ss; 10 char we[50]; 11 char s[10][20] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; 12 int main() 13 { 14 int k,y,o,i; 15 while(cin>>we>>ll>>ss) 16 { 17 double kk = ll/ss; 18 for(i = 0 ; i < 7 ; i++) 19 if(strcmp(we,s[i])==0) 20 { 21 y = i; 22 break; 23 } 24 k = ll/ss; 25 if(kk!=k) 26 k++; 27 if(y<=4) 28 k+=y*8; 29 else 30 k += 8*5+(y-5)*4; 31 o = 8*5+8; 32 k = k%o; 33 if(k==0) 34 k = 48; 35 if(k<=8) 36 printf("%s ",s[0]); 37 else if(k>8&&k<=16) 38 printf("%s ",s[1]); 39 else if(k>16&&k<=24) 40 printf("%s ",s[2]); 41 else if(k>24&&k<=32) 42 printf("%s ",s[3]); 43 else if(k>32&&k<=40) 44 printf("%s ",s[4]); 45 else if(k>40&&k<=44) 46 printf("%s ",s[5]); 47 else 48 printf("%s ",s[6]); 49 } 50 return 0; 51 }