fork download
  1. #include <stdio.h>
  2. #include<string.h>
  3. int main(void) {
  4. int c, m, d, i, m1[13]={31,31,28,31,30,31,30,31,31,30,31,30,31};
  5. char s[10], w[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
  6. scanf("%d",&c);
  7. while(c--){
  8. scanf("%d%d%s",&m,&d,s);
  9. for(i=0;i<7;i++)
  10. if(strcmp(w[i],s)==0)
  11. break;
  12. //printf("%s\n",w[i]);
  13. d-=i;
  14. if(d<1){
  15. m-=1;
  16. //if(m%2==1) d+=31;
  17. //else if(m==2) d+=28;
  18. //else d+=30;
  19. d+=m1[m];
  20. }
  21. printf("%d",d++);
  22. for(i=0;i<6;i++){
  23. if(d>m1[m])
  24. //if((m==2)||(m%2==0&&d>30)||(d>31))
  25. d=1;
  26. printf(" %d",d++);
  27. }
  28. printf("\n");
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 2252KB
stdin
5
7 27 Saturday
7 27 Sunday
7 28 Sunday
7 28 Monday
7 29 Tuesday
stdout
21 22 23 24 25 26 27
27 28 29 30 31 1 2
28 29 30 31 1 2 3
27 28 29 30 31 1 2
27 28 29 30 31 1 2