这个是1984年1月1日是星期日的,你先看看,我再帮你改,最好自己能看懂
#include
void main()
{
int year,month,day;
int tempmonth,yearday;
int week,weekday;
unsigned int sum=0;
int tag=0;
printf("输入年、月、日:\n");
scanf("%d %d %d",&year,&month,&day);
tag =( year - 1980 )/4;
sum=(year-1984)*365 + tag;
tempmonth = month - 1;
yearday = 0;
switch(tempmonth)
{
case 12:yearday+=31;
case 11:yearday+=30;
case 10:yearday+=31;
case 9:yearday+=30;
case 8:yearday+=31;
case 7:yearday+=31;
case 6:yearday+=30;
case 5:yearday+=31;
case 4:yearday+=30;
case 3:yearday+=31;
case 2:yearday+=28;
case 1:yearday+=31;
}
yearday = yearday+day;
if ((year-1984)%4==0 && month > 2)
{
yearday+=1;
}
sum=sum+yearday;
if (year==1984)
{
sum-=1;
}
printf("距1984年1月1日一共有%d天\n",sum);
/*上面是计算输入的日期距1984年1月1日一共经历了多少天*/
weekday = (sum-1) % 7;
week = yearday / 7;
printf("今天是第%d个星期,星期%d",week,weekday);
return ;
}
下面是修改好的,能多给些分嘛?写程序不容易,还有,好好学习,这些不难,就是多花点时间而已
#include
void main()
{
int year,month,day;
int tempmonth,yearday;
int week,weekday;
int sum=0;
int tag=0;
printf("输入年、月、日:\n");
scanf("%d %d %d",&year,&month,&day);
tag =( year - 1988 )/4;
printf("tag=%d\n",tag);
sum=(year-1990)*365 + tag;
tempmonth = month - 1;
yearday = 0;
switch(tempmonth)
{
case 12:yearday+=31;
case 11:yearday+=30;
case 10:yearday+=31;
case 9:yearday+=30;
case 8:yearday+=31;
case 7:yearday+=31;
case 6:yearday+=30;
case 5:yearday+=31;
case 4:yearday+=30;
case 3:yearday+=31;
case 2:yearday+=28;
case 1:yearday+=31;
}
yearday = yearday+day;
if ((year-1988)%4==0 && month > 2)
{
yearday+=1;
}
sum=sum+yearday;
printf("sum=%d\n",sum);
printf("距1990年1月1日一共有%d天\n",sum);
/*上面是计算输入的日期距1990年1月1日一共经历了多少天*/
weekday = (sum-1) % 7+1;
week = yearday / 7;
printf("今天是第%d个星期,星期%d",week,weekday);
return ;
}
#include
bool leap_year(int &year)
{
if(year%4==0&&year%100!=0||year%400==0)
return true;
return false;
}
void main()
{
int a[12]=
{31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,days;
scanf("%d %d %d",&year,&month,&days);
int sum=0,orig=1990;
while(year>orig)
{
sum=sum+(leap_year(orig)?366:365);
++orig;
}
if(leap_year(year))a[1]=29;
for(int i=0;i!=month-1;++i)
sum+=a[i];
sum+=days;
int weeks=sum%7;
printf("%d\n",weeks);
}
#include
int main()
{
int a;
printf("今天是周日嘎~请输入一个数字(正整数哦)我会告诉你是礼拜几嘎\n安心输入把~要诚实哦:\n 退出请输入8\n");
while(true)
{
scanf("%d",&a);
switch(a)
{
case 1:printf("是周一哦\n");return 0;
case 2:printf("是周二哦\n");return 0;
case 3:printf("是周三哦\n");return 0;
case 4:printf("是周四哦\n");return 0;
case 5:printf("是周五哦\n");return 0;
case 6:printf("是周六哦\n");return 0;
case 8: return 0;
default:printf("请再次输入\n");break;
}
}
}