谢啦。。。。。~~~~~~~~
#include<stdio.h>
#include<stdlib.h>
void main()
{
int day_num[][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 data[3],week_leap,leap,i;
long day=0;
char data_ptr[3][8]={"年份:","月份:","日期:"};
char week[][4]={"一","二","三","四","五","六","日"};
//输入和输入限制
for(i=0;i<3;i++)
{
printf("请输入您所要的%s:",data_ptr[i]);
scanf("%d",data+i);
}
if(data[0]<1900||data[0]>9999||
data[1]<1||data[1]>12||
data[2]<1||data[2]>31)
{printf("输入错误\n");exit(1);}
printf("您所输入的是%d年%d月%d日\n",data[0],data[1],data[2]);
//判断闰年次数(到输入的年份前一年)
for(i=1900;i<data[0];i++)
if(((i%4==0)&&(i%100!=0))||(i%400==0))
day++;
//计算从1900年1月1日到现在有多少天
if(((data[0]%4==0)&&(data[0]%100!=0))||(data[0]%400==0))
leap=1;
else leap=0;
for(i=1;i<data[1];i++)
day=day+day_num[leap][i];
day=day+365*(data[0]-1900)+data[2]-1;
//计算星期并输出
week_leap=day%7;
printf("%d年%d月%d日是星期%s\n",data[0],data[1],data[2],week[week_leap]);
}