代码没有任何报错,但是一直输出错误,为什么啊😭
输入某年某月某日,判断这一天是这一年的第几天?#include<stdio.h>
int main()
{
int year, month, day, leaf, sum;
printf("please show years, month, days(like: 2015,3,20)");
scanf("&d,%d,%d", &year, &month, &day);
switch(month){
case 1:sum=0;break;
case 2:sum=31;break;
case 3:sum=59;break;
case 4:sum=90;break;
case 5:sum=120;break;
case 6:sum=151;break;
case 7:sum=181;break;
case 8:sum=212;break;
case 9:sum=243;break;
case 10:sum=273;break;
case 11:sum=304;break;
case 12:sum=334;break;
default:printf("data error");break;
}
sum+=day;
if(year%400==0||(year%4==0&&year%100!=0)){
leaf = 1;
}
else{
leaf = 0;
}
if(leaf==1&&month>2){
sum++;
}
printf("It's the %d day of the year", sum);
printf("\n");
} scanf("&d,%d,%d", &year, &month, &day);
仔细看,发现什么没有 wp231957 发表于 2023-3-4 07:03
scanf("&d,%d,%d", &year, &month, &day);
仔细看,发现什么没有
我把这个改了还是一直输出错误{:5_100:} wwWsir 发表于 2023-3-4 08:06
我把这个改了还是一直输出错误
错误信息发出来 scanf("&d,%d,%d", &year, &month, &day);
这段代码不知道你改成什么了,明显的错误是 &d scanf("&d,%d,%d", &year, &month, &day);
改成
scanf("%d,%d,%d", &year, &month, &day);{:10_256:} wp231957 发表于 2023-3-4 08:08
错误信息发出来
我明白了,我输入有问题,输入的时候也不能用中文逗号
页:
[1]