鱼C论坛

 找回密码
 立即注册
查看: 2159|回复: 4

[已解决]关于if的用法

[复制链接]
发表于 2021-2-14 14:49:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
        int score;
        scanf(" %d",&score);
        if( score < 60)
        {
                printf ("The score is E !\n");
        }
        else if( (score > 60|| score == 60) && score < 70);
        {
                printf("The score is D !\n");
        }
        else if((score>70 || score == 70)  &&score <80);
        {
                printf(" The score is C!\n");
        }
        else if ((score > 80) ||score == 80 )&& score < 90);
        {
                printf("The score is B!\n");
        }
        else if ( 90 <= score);
        {
                printf("The score is A!\n");
        }
大佬们能帮忙看看哪里出错了吗
最佳答案
2021-2-14 15:24:45
  1. #include <stdio.h>


  2. int main()
  3. {
  4.         int score;
  5.         scanf("%d",&score);
  6.         if( score < 60)
  7.         {
  8.                 printf ("The score is E !\n");
  9.         }
  10.         else if( (score > 60|| score == 60) && score < 70)
  11.         {
  12.                 printf("The score is D !\n");
  13.         }
  14.         else if((score>70 || score == 70)  &&score <80)
  15.         {
  16.                 printf(" The score is C!\n");
  17.         }
  18.         else if ((score > 80 ||score == 80 )&& score < 90)
  19.         {
  20.                 printf("The score is B!\n");
  21.         }
  22.         else
  23.         {
  24.                 printf("The score is A!\n");
  25.         }
  26. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-2-14 15:14:42 | 显示全部楼层
scanf(" %d",&score);这句%d前边多一个空格
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-14 15:16:00 | 显示全部楼层
还有else if语句后边的分号去掉
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-14 15:24:45 | 显示全部楼层    本楼为最佳答案   
  1. #include <stdio.h>


  2. int main()
  3. {
  4.         int score;
  5.         scanf("%d",&score);
  6.         if( score < 60)
  7.         {
  8.                 printf ("The score is E !\n");
  9.         }
  10.         else if( (score > 60|| score == 60) && score < 70)
  11.         {
  12.                 printf("The score is D !\n");
  13.         }
  14.         else if((score>70 || score == 70)  &&score <80)
  15.         {
  16.                 printf(" The score is C!\n");
  17.         }
  18.         else if ((score > 80 ||score == 80 )&& score < 90)
  19.         {
  20.                 printf("The score is B!\n");
  21.         }
  22.         else
  23.         {
  24.                 printf("The score is A!\n");
  25.         }
  26. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-2-14 15:45:47 | 显示全部楼层
非常感谢!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-26 07:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表