C语言swich分支结构

codeblock编写C程序,可以正常运行,但输出结果不正确
switch分支条件如下:
s<250 没有折扣
250<=s<500 d=2
500<=s<1000 d=5
1000<=s<2000 d=8
2000<=s<3000 d=10
3000<=s d=15
程序代码如下:

#include 
#include 

int main()
{
    int c,s;
    float p,w,d,f;
    printf("please enter price,weight,discount:");
    scanf("%f,%f,%d",&p,&w,&s);
    if(s>=3000)
        c=12;
    else
        c=s/250;
    switch(c)
    {
        case0: d=0;break;
        case1: d=2;break;
        case2:
        case3: d=5;break;
        case4:
        case5:
        case6:
        case7: d=8;break;
        case8:
        case9:
        case10:
        case11: d=10;break;
        case12: d=15;break;
    }
    f=p*w*s*(1-d/100);
    printf("freight=%10.2f\n",f);
    return 0;
}

运行截图如下:

img


正确结果应为588000.00

case和数字之间要有空格, 如case 0

case后边没空格么,至少加个空格呀 case 0:

img

case 后面要有空格