问答详情
源自:4-16 分支结构之switch语句

哪里不对呢


#include "stdio.h"

 main()

 {

char grade;

printf("\ninput grade:");

scanf("%f",&grade);

grade=grade/=10;

switch(grade)

{

case 10:

case 9:printf("\n A");break;

case 8:printf("\n B");break;

case 7:printf("\n C");break;

case 6:printf("\n D");break;

default:printf("\n E");break;

}

 

}


提问者:慕无忌4368783 2018-10-09 11:36

个回答

  • qq_寄曲束菀令_dpsJS0
    2018-10-09 13:25:03

    char 不是单个字符吗?    %f 不是单浮点标量吗,,,,

  • qq_寄曲束菀令_dpsJS0
    2018-10-09 13:22:44

    #include<stdio.h>

     main()

     {

    int grade;

    printf("\ninput grade:");

    scanf("%d",&grade);

    grade=int(grade/10);

    switch(grade)

    {

    case 10:

    case 9:printf("\n A");break;

    case 8:printf("\n B");break;

    case 7:printf("\n C");break;

    case 6:printf("\n D");break;

    default:printf("\n E");break;

    }

     

    }