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/04/29 04:05:56

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

如果switch执行了default路径,discount就没有初始化.比如给distance赋个负数.就算不存在这种情况,按照代码逻辑来说default路径不可能被执行,但编译器也还没聪明到能够发现这一事实.

variable The variable hough_circle is also the name of this script. you need to define the enviromental variable FLUENT_INC illegal modifier for the variable conn; only final is permitted 英语翻译we predict that the attributes of one variable differ with respect to the attributes of a second variable variable是什么意思? variable是什么意思 请问the variable of interest是什么意思?在经济学的范畴内 The completive sentence:The variable of interest is divided into categories or outcomes. 安装oracle 出现Environment variable:PATH -Environment variable:PATH - This test checks whether the length of the environment variable PATH does not exceed the recommended length.预期值:1023实际值:1184错误列表:- PRVF-3929 :Adding t 英语翻译when the signals areone-dimensional,the independent variable is referred to as “time” 英语翻译A marginal amount of a particular variable is the increment in that variable induced by a change in another variable on which it depends这句该怎么翻译? the java_home environment variable is not defined correctlyThis environment variable is needed to run this programNB:java_home should point to a jdk not a jre 程序出错:The variable 'y' is being used without being initialized. Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted. 英语翻译The diminishing returns of a variable input will account for: 英语翻译The diminishing returns of a variable input will account for: long run is the period of time in which all inputs are variable翻译 启动eclipse时总提示The environment variable HOME is not set.怎么解决