求助!实在是破防了
#include <stdio.h>int main(void)
{
double ch=
{
{0,0,0,0,0,0,0,31.3,35.5,58.7,49.6,55.5},
{59.8,54.9,33.1,38.2,26.6,20.5,27.8,38.5,41.5,44.7,38.1,41.5},
{34.9,36.4,47.5,37.9,30.6,23.4,26.6,34.3,0,0,0,0}
};
int year=0,month=0;
printf("请输入待查询年月份(年-月):");
scanf("%d-%d",&year,&month);
year-=2014;
if(year<0 || year>3)
{
printf("抱歉,该年份未收录数据。");
goto A;
}
else if(month>12 || month<0)
{
printf("抱歉,月份输入错误。");
goto A;
}
else if(ch='\0')
{
printf("抱歉,该月份未收录数据。");
goto A;
}
printf("%d年%d月广州的PM2.5值是%llf",year+2014,month,ch);
A:
return 0;
}
这是代码
这是调试时候的结果
这是正常运算的结果
结果竟然不一样!
我重启电脑都试过了,都没用
还有那个结果,我数组设置的是double类型的,但是%llf却输出不了数据 else if(ch=='\0') #include <stdio.h>
int main(void)
{
double ch=
{
{0,0,0,0,0,0,0,31.3,35.5,58.7,49.6,55.5},
{59.8,54.9,33.1,38.2,26.6,20.5,27.8,38.5,41.5,44.7,38.1,41.5},
{34.9,36.4,47.5,37.9,30.6,23.4,26.6,34.3,0,0,0,0}
};
int year=0,month=0;
printf("请输入待查询年月份(年-月):");
scanf("%d-%d",&year,&month);
year-=2014;
if(year<0 || year>3)
{
printf("抱歉,该年份未收录数据。");
goto A;
}
else if(month>12 || month<0)
{
printf("抱歉,月份输入错误。");
goto A;
}
else if(ch=='\0')// 这里要写成==,不然在判断的时候就会把ch设置成0,所以你打印的结果就是0
{
printf("抱歉,该月份未收录数据。");
goto A;
}
printf("%d年%d月广州的PM2.5值是%llf",year+2014,month,ch);
A:
return 0;
} 这用的啥软件啊,看着头疼 else if(ch=='\0')
页:
[1]