猿问

求大神帮我看一下哪里出错了

#include <stdio.h>
int main ()
{
    double score;
    printf("please enter score:\n");
    scanf("%if",&score);
    if(score>100||score<0)
    {
        printf("error!\n please again!\n");
        scanf("%if",&score);
    }
    switch ((int)score/10)
    {
        case 0:printf("E\n");break ;
        case 1:printf("E\n");break ;
        case 2:printf("E\n");break ;
        case 3:printf("E\n");break ;
        case 4:printf("E\n");break ;
        case 5:printf("E\n");break ;
        case 6:printf("D\n");break ;
        case 7:printf("C\n");break ;
        case 8:printf("B\n");break ;
        case 9:printf("A\n");break ;
        case 10:printf("A\n");break ;
    }
    return 0;
}

ASLyo
浏览 2315回答 3
3回答

慕用4063026

#include <stdio.h>int main (){    float score;    printf("please enter score:\n");    scanf("%f",&score);    if(score>100||score<0)    {        printf("error!\n please again!\n");        scanf("%f",&score);    }    switch ((int)score/10)    {        case 0:printf("E\n");break ;        case 1:printf("E\n");break ;        case 2:printf("E\n");break ;        case 3:printf("E\n");break ;        case 4:printf("E\n");break ;        case 5:printf("E\n");break ;        case 6:printf("D\n");break ;        case 7:printf("C\n");break ;        case 8:printf("B\n");break ;        case 9:printf("A\n");break ;        case 10:printf("A\n");break ;    }    return 0;}输入:70输出:please enter score:C你的输入scanf("%f",&score); 有问题,怎么会if

木柘

#include <stdio.h> int main () { double score; printf("Please enter score: "); scanf("%lf",&score); if (score > 100 || score < 0) { printf("Error! Please enter again!\n"); scanf("%lf",&score); } switch ((int)score/10) { case 0: printf("E\n"); break ; case 1: printf("E\n"); break ; case 2: printf("E\n"); break ; case 3: printf("E\n"); break ; case 4: printf("E\n"); break ; case 5: printf("E\n"); break ; case 6: printf("D\n"); break ; case 7: printf("C\n"); break ; case 8: printf("B\n"); break ; case 9: printf("A\n"); break ; case 10: printf("A\n"); break ; } return 0; }格式化输入。

ASLyo

为什么运行的时候不管输入什么分数,都是E
随时随地看视频慕课网APP
我要回答