码迷,mamicode.com
首页 > 其他好文 > 详细

1.1.3Friday the Thirteenth

时间:2015-05-31 13:53:39      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:

  1. /*
  2. ID: awsd1231
  3. PROG: friday
  4. LANG: C++
  5. */
  6. #include<iostream>
  7. #include<cstdio>
  8. usingnamespace std;
  9. constint monthDay[12]={31,0,31,30,31,30,31,31,30,31,30,31};
  10. int main(){
  11. freopen("friday.in","r", stdin);
  12. freopen("friday.out","w", stdout);
  13. int year =1900;
  14. int today =6;
  15. int week[8]={0};
  16. week[6]++;
  17. int n;
  18. cin >> n;
  19. for(int i =0; i != n;++i){
  20. for(int j =0; j !=12;++j){
  21. if(j ==1)
  22. if((year+i)%4==0&&(year+i)%100!=0||(year+i)%400==0)
  23. today =(today +29)%7;
  24. else
  25. today =(today +28)%7;
  26. else
  27. today =(today + monthDay[j])%7;
  28. week[today]++;
  29. // cout << j+2 << "月:" << today << endl;
  30. }
  31. }
  32. week[today]--;
  33. cout << week[6]<<" ";
  34. for(int i =0; i !=5; i++)
  35. cout << week[i]<<" ";
  36. cout << week[5];
  37. cout << endl;
  38. return0;
  39. }
 





1.1.3Friday the Thirteenth

标签:

原文地址:http://www.cnblogs.com/liangyongrui/p/4541850.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!