首页 > 代码库 > oj---九度oj---1043----day of week
oj---九度oj---1043----day of week
#include<cstdio> #include<cstring> int isleap(int n){ if((n%100!=0&&n%4==0)||n%400==0) return 1; else return 0; } int dayofmonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31, }; //****// char monthname[13][20]={ "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; char dayname[7][20]={ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; struct date{ int d; int m; int y; void nextday(){ d++; if(d>dayofmonth[m][isleap(y)]){ m++; d=1; if(m>12){ m=1; y++; } } } }; int process[5005][13][32]; int abs(int x){ return x<0?-x:x; } int main(){ date tmp; int cnt=0; tmp.d=1; tmp.m=1; tmp.y=0; while(tmp.y!=5001){ process[tmp.y][tmp.m][tmp.d]=cnt; tmp.nextday(); cnt++; } int d,m,y; char s[20]; while(scanf("%d%s%d",&d,s,&y)!=EOF){ for(m=1;m<=12;m++){ if(strcmp(s,monthname[m])==0) break; } int days=process[y][m][d]-process[2017][6][25]; puts(dayname[(days%7+7)%7]); } return 0; }
oj---九度oj---1043----day of week
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。