早教吧作业答案频道 -->其他-->
#includevoidmain(){doublep,w,a,d,f;scanf("%lf%lf%lf",&p,&w,&a);{ifa>=3000d=15;elseifa>=2000d=10;elseifa>=1000d=8;elseifa>=500d=5;elseifa>=250d=2;elsed=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)
这是怎么了?
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)
这是怎么了?
▼优质解答
答案和解析
if a>=3000 改成 if (a>=3000),后面的if都要改.
看了 #includevoidma...的网友还看了以下:
屏幕上用“*”显示0-360度的余弦函数cos(x)曲线#include #include int 2020-05-16 …
#includemain(){inta=0x7fffffff,b=025;floatf1=123. 2020-05-19 …
请问fscanf(inp,"%lf,%lf,%lf\n",&c1,&c2,&c3)什么意思?fsc 2020-06-06 …
#includevoidmain(){doublep,w,a,d,f;scanf("%lf%lf% 2020-07-23 …
C语言函数指针问题~~~~~~~~~~以下是我写一个程序:#include"stdio.h"#in 2020-07-23 …
main(){intg;printf("Enteramark:");scarf("%d",&g); 2020-07-25 …
计算π的近似值.公式如下:π/4=1-1/3+1/5-1/7+……,直到最后一项的绝对值小于10- 2020-08-02 …
看下这个C程序哪里错了,求二元一次方程的根#includevoidmain()doublet1,t2 2020-11-23 …
WPS表格敢不敢有这种公式A,B,C,D四个格子,A-B=C,D为公式lF(B<25且C>=0WPS 2020-11-29 …
若有定义floatw;inta,b;,则合法的switch语句是()。(1分)A、switch(w) 2021-01-13 …