关于这个程序的错误之处

来源:百度知道 编辑:UC知道 时间:2024/05/16 19:34:08
如题
#include <stdio.h>
main()
{
int year,month,date,j,i,p,sum,count,days,q;
char x;
printf("please input the year month date\n");
scanf("%d %d %d",&year,&month,&date);
switch (month)
{case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
i=31;
break;

case 4:
case 6:
case 9:
case 11:
i=30;
break;
case 2:
if (year%400==0||(year%4==0&&year%100!=0))
i=29;
else
i=28;

}
count=0;
for (p=2000;p<=(year-1);p++)
if (year%400==0||(year%4==0&&year%100!=0))
count++;

sum=0;

for (j=1;j<=(month-1);j++)
sum+=i;

days=(year-2000)*365+count+sum+date;
q=(days+6)%7;
switch (q)
{case 0:
x ="today is sunday";
break;
case 1:
x =&q

“x=”应改为printf("today is...");
最后加上返回值return 0;或者开头用void main()

#include <stdio.h>
#include <string>
main()
{
int year,month,date,j,i,p,sum,count,days,q;
string x;
printf("please input the year month date\n");
scanf("%d %d %d",&year,&month,&date);
switch (month)
{case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
i=31;
break;

case 4:
case 6:
case 9:
case 11:
i=30;
break;
case 2:
if (year%400==0||(year%4==0&&year%100!=0))
i=29;
else
i=28;

}
count=0;
for (p=2000;p<=(year-1);p++)
if (year%400==0||(year%4==0&&year%100!=0))
count++;

sum=0;

for (j=1;j<=(month-1);j++)
sum+=i;

days=(year-2000)*365+count+sum+date;
q=(days+6)%7;