the variable'discount' is being used without being initializedint _tmain(int argc,_TCHAR* argv[]){float price,weigh,distance,f,discount;int c;printf("Please enter the price,weigh,distance:\n");scanf("%lf%lf%lf",&price,&weigh,&distance);if(distance>=3
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 07:59:26
the variable'discount' is being used without being initializedint _tmain(int argc,_TCHAR* argv[]){float price,weigh,distance,f,discount;int c;printf("Please enter the price,weigh,distance:\n");scanf("%lf%lf%lf",&price,&weigh,&distance);if(distance>=3
the variable'discount' is being used without being initialized
int _tmain(int argc,_TCHAR* argv[])
{float price,weigh,distance,f,discount;
int c;
printf("Please enter the price,weigh,distance:\n");
scanf("%lf%lf%lf",&price,&weigh,&distance);
if(distance>=3000)
c=12;
else c=distance/250;
switch(c)
{case 0:discount=0;break;
case 1:discount=2;break;
case 2:
case 3:discount=5;break;
case 4:
case 5:
case 6:
case 7:discount=8;break;
case 8:
case 9:
case 10:
case 11:discount=10;break;
case 12:discount=15;break;
default:printf("\!\n");}
f=price*distance*weigh*(1-discount/100);
printf("You have to pay %10.2f\n",f);
return 0;
}
dicount 已经被初始了啊
是discount
the variable'discount' is being used without being initializedint _tmain(int argc,_TCHAR* argv[]){float price,weigh,distance,f,discount;int c;printf("Please enter the price,weigh,distance:\n");scanf("%lf%lf%lf",&price,&weigh,&distance);if(distance>=3
如果switch执行了default路径,discount就没有初始化.比如给distance赋个负数.就算不存在这种情况,按照代码逻辑来说default路径不可能被执行,但编译器也还没聪明到能够发现这一事实.