日期-北大-2080

0 views
Skip to first unread message

china_sjc

unread,
Aug 6, 2008, 6:28:04 AM8/6/08
to 中国矿业大学徐海学院算法课程
#include"stdio.h"
char week[7]
[10]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
int year[2]={365,366};
int month[2]
[12]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};

int type(int m)
{if((m%4==0&&m%100!=0)||(m%400==0))return 1;else return 0;
}
void main()
{
int days,dayofweek;
int i=0,j=0;
while(scanf("%d",&days)&&days!=-1)
{
dayofweek=days%7;
for(i=2000;days>=year[type(i)];i++)
days-=year[type(i)];
for(j=0;days>=month[type(i)][j];j++)
days-=month[type(i)][j];
printf("%d-%02d-%02d %s\n",i,j+1,days+1,week[dayofweek]);

}
}
Reply all
Reply to author
Forward
0 new messages