#include <stdio.h>
#include <stdlib.h>
#define baseYear 2000
void Week(int num, char *pWeek)
{
char Week[][12] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
*pWeek = Week[num%7 - 1][12];
}
void Year(int *pNum, int *pYear)
{
int i;
for(i=1;*pNum<365;i++)
{
if((i%4==0&&i%100!=0)||(i%400==0))
{
*pNum=*pNum-366;
}
else
{
*pNum=*pNum-365;
}
}
*pYear=baseYear + i;
}
void Month(int num,int year,int *pMonth,int *pDay)
{
int monthDay[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int i;
int flag;
flag = (i%4==0&&i%100!=0)||(i%400==0);
for (i=1;num<monthDay[flag][i];i++)
{
num = num-monthDay[flag][i];
}
*pMonth = i;
*pDay = num;
}
int main()
{
int num;
int year,month,day;
int week[12];
printf("Please enter the number:");
scanf("%d",&num);
Week(num,week);
Year(&num,&year);
Month(num,year,&month,&day);
printf("\n%d-%d-%d ",year,month,day,week);
return 0;
}
万年历的程序 各位应该知道吧 帮我找找bug吧 多谢