解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h> using namespace std; #define rn(y) (((y%4==0)&&(y%100!=0))||(y%400==0))?true:false int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; int main() { int n,site=3,sum=0; //site纪录星期位置0~6; cin >> n; for (int i = 1998; i <=n; i++) { if (rn(i)) month[2] = 29; else month[2] = 28; for (int j = 1; j < 13; j++) { if(i==n)if ((site + 12) % 7 == 4) sum++; site = (site + month[j]) % 7; } } cout << sum; }
0.0分
6 人评分
Tom数 (C语言代码)浏览:2012 |
点我有惊喜!你懂得!浏览:4109 |
A+B for Input-Output Practice (IV) (C++代码)浏览:677 |
Pascal三角 (C语言代码)格式错误浏览:520 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:375 |
【偶数求和】 (C语言代码)浏览:646 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:916 |
核桃的数量 (C语言代码)浏览:671 |
母牛的故事 (C语言代码)浏览:944 |