#includevoid main(){double p,w,a,d,f;scanf("%lf %lf %lf",&p,&w,&a);{if a>=3000 d=15;else if a>=2000 d=10;else if a>=1000 d=8;else if a>=500 d=5;else if a>=250 d=2;else d=0;}f=p*w*a*(1-d/100);printf("%lf",f);}--------------------Configuration:r1 - Win
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/20 17:16:07
![#includevoid main(){double p,w,a,d,f;scanf(](/uploads/image/z/14843337-33-7.jpg?t=%23includevoid+main%28%29%7Bdouble+p%2Cw%2Ca%2Cd%2Cf%3Bscanf%28%22%25lf+%25lf+%25lf%22%2C%26p%2C%26w%2C%26a%29%3B%7Bif+a%3E%3D3000+d%3D15%3Belse+if+a%3E%3D2000+d%3D10%3Belse+if+a%3E%3D1000+d%3D8%3Belse+if+a%3E%3D500+d%3D5%3Belse+if+a%3E%3D250+d%3D2%3Belse+d%3D0%3B%7Df%3Dp%2Aw%2Aa%2A%281-d%2F100%29%3Bprintf%28%22%25lf%22%2Cf%29%3B%7D--------------------Configuration%3Ar1+-+Win)
#includevoid main(){double p,w,a,d,f;scanf("%lf %lf %lf",&p,&w,&a);{if a>=3000 d=15;else if a>=2000 d=10;else if a>=1000 d=8;else if a>=500 d=5;else if a>=250 d=2;else d=0;}f=p*w*a*(1-d/100);printf("%lf",f);}--------------------Configuration:r1 - Win
#include
void main()
{
double p,w,a,d,f;
scanf("%lf %lf %lf",&p,&w,&a);
{
if a>=3000 d=15;
else if a>=2000 d=10;
else if a>=1000 d=8;
else if a>=500 d=5;
else if a>=250 d=2;
else d=0;
}
f=p*w*a*(1-d/100);
printf("%lf",f);
}
--------------------Configuration:r1 - Win32 Debug--------------------
Compiling...
r1.cpp
D:\试练\r1.cpp(7) :error C2061:syntax error :identifier 'a'
D:\试练\r1.cpp(8) :error C2181:illegal else without matching if
D:\试练\r1.cpp(8) :error C2061:syntax error :identifier 'a'
D:\试练\r1.cpp(9) :error C2181:illegal else without matching if
D:\试练\r1.cpp(9) :error C2061:syntax error :identifier 'a'
D:\试练\r1.cpp(10) :error C2181:illegal else without matching if
D:\试练\r1.cpp(10) :error C2061:syntax error :identifier 'a'
D:\试练\r1.cpp(11) :error C2181:illegal else without matching if
D:\试练\r1.cpp(11) :error C2061:syntax error :identifier 'a'
D:\试练\r1.cpp(12) :error C2181:illegal else without matching if
执行 cl.exe 时出错.
r1.obj - 1 error(s),0 warning(s)
这是怎么了?
#includevoid main(){double p,w,a,d,f;scanf("%lf %lf %lf",&p,&w,&a);{if a>=3000 d=15;else if a>=2000 d=10;else if a>=1000 d=8;else if a>=500 d=5;else if a>=250 d=2;else d=0;}f=p*w*a*(1-d/100);printf("%lf",f);}--------------------Configuration:r1 - Win
if a>=3000 改成 if (a>=3000),后面的if都要改.