解题思路:
记住公式,输入年月日,输出星期几:int week=(dd+2*mm+3*(mm+1)/5+yy+yy/4-yy/100+yy/400)%7; #include <iostream> #include <cstdlib> #include <cmath> #include <deque> #include <algorithm> #include <numeric> #include <iterator> #include <sstream> #include <iomanip> #include <vector> #include <string.h> #include <string> using namespace std; int ans; void fun(int yy,int mm,int dd) { if(mm==1||mm==2) { mm+=12; yy--; } int week=(dd+2*mm+3*(mm+1)/5+yy+yy/4-yy/100+yy/400)%7; switch(week) { case 0:break; case 1:break; case 2:break; case 3:break; case 4:ans++;break; case 5:break; case 6:break; } } int main() { int yy,dd; cin>>yy; for(int i=1;i<=12;i++) { fun(yy,i,13); } cout<<ans<<endl; return 0; }
注意事项:
参考代码:
0.0分
0 人评分
妹子杀手的故事 (C语言代码)浏览:688 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:810 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:600 |
C语言训练-计算一个整数N的阶乘 (C语言代码)浏览:933 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:559 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:509 |
【金明的预算方案】 (C++代码)浏览:939 |
IP判断 (C语言代码)浏览:763 |
The 3n + 1 problem (C语言代码)浏览:552 |
杨辉三角 (C语言代码)浏览:484 |