switch case的用法总是不懂,可以帮我看看case部分有哪里错了吗?
#include<stdio.h>int main()
{
float x,y;
scanf("%f",&x);
switch(x)
{
case x<=1000:y=0;break;
case x<=2000:y=x*0.05;break;
case x<=3000:y=x*0.1;break;
case x<=6000:y=x*0.15;break;
case x>6000:y=x*0.2;break;
}
printf("tax=%.2f,money=%.2f",x,y);
return 0;
}
以下是错误提示
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c||In function 'main':|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|6|error: switch quantity not an integer|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|8|error: case label does not reduce to an integer constant|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|9|error: case label does not reduce to an integer constant|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|10|error: case label does not reduce to an integer constant|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|11|error: case label does not reduce to an integer constant|
C:\Users\dell\Desktop\c语言\绝对值\switch case1.c|12|error: case label does not reduce to an integer constant|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|