error C2085: 'f' : not in formal pa
#include<stdio.h>main()intf,m,a,s;floatb;scanf("%d,%d,%d,%d",&f,&m,&a,&s);switch(s){c...
#include<stdio.h>
main()
int f,m,a,s;
float b;
scanf("%d,%d,%d,%d",&f,&m,&a,&s);
switch(s){
case 1:b=(f+m)*1.08/2;break;
case 0:b=(f*0.923+m)/2;break;
}
if(-3<=b-a<=3)
printf("right");
else printf("false");
}
c1.c
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'f' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'm' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'a' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 's' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(4) : error C2085: 'b' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(5) : error C2061: syntax error : identifier 'scanf'
C:\Users\Administrator\Desktop\c1.c(6) : error C2059: syntax error : 'switch'
C:\Users\Administrator\Desktop\c1.c(9) : fatal error C1506: unrecoverable block scoping error
执行 cl.exe 时出错.
c1.exe - 1 error(s), 0 warning(s) 展开
main()
int f,m,a,s;
float b;
scanf("%d,%d,%d,%d",&f,&m,&a,&s);
switch(s){
case 1:b=(f+m)*1.08/2;break;
case 0:b=(f*0.923+m)/2;break;
}
if(-3<=b-a<=3)
printf("right");
else printf("false");
}
c1.c
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'f' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'm' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 'a' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(3) : error C2085: 's' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(4) : error C2085: 'b' : not in formal parameter list
C:\Users\Administrator\Desktop\c1.c(5) : error C2061: syntax error : identifier 'scanf'
C:\Users\Administrator\Desktop\c1.c(6) : error C2059: syntax error : 'switch'
C:\Users\Administrator\Desktop\c1.c(9) : fatal error C1506: unrecoverable block scoping error
执行 cl.exe 时出错.
c1.exe - 1 error(s), 0 warning(s) 展开
1个回答
展开全部
#include<stdio.h>
int main()
{ //这少花括号
int f,m,a,s;
float b;
scanf("%d,%d,%d,%d",&f,&m,&a,&s);
switch(s)
{
case 1:
b=(f+m)*1.08/2;
break;
case 0:
b=(f*0.923+m)/2;
break;
default: //加个default 分支,否则b可能有未初始化就使用的情况
b = 0.0;
break;
}
if(-3<=(b-a) && (b-a)<=3 ) //这的条件语句写错了。
printf("right");
else
printf("false");
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询