文章
20
粉丝
412
获赞
13
访问
165.3k
#include <iostream>
using namespace std;
bool isLeap(int x) {
if(x % 4 == 0 && x % 100 != 0 || x % 400 == 0)
return true;
else return false;
}
int main() {
int year, month, day, sum = 0;
int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
char weekday[7][20] = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
scanf("%d,%d,%d", &year, &month, &day);
if(isLeap(year)) days[2] = 29;
for(int i = 2012;i < year;i++) { //以2012年1月1日星期日为基准
if(isLeap(i)) sum += 366;
else sum += 365;
}
for(int i = 1;i < month;i++)
sum += days[i];
sum += day-1;
cout << weekday[sum%7] << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发