c - 为什么下面代码中C语言的else命令所在行没有被读取?

标签 c

#include<stdio.h>
#include<conio.h>
void main()
{ 
int a,b,c;
printf("\n Enter any three numbers");
scanf("%d%d%d", &a,&b,&c);

if(a > b){
  if(a > c){
    printf("\n The greatest number is =%d",a);
  }
} else
    if(b > a) {
      if(b > c) { 
        printf("\n The greatest number is =%d",b);
      }
    } else {
      printf("\nThe greatest number=%d",c);
    }
getch();
}

当第三个数字最大时,屏幕上没有输出。我尝试使用 F7 并发现带有“else”语句的行被跳过。因为我只需要使用嵌套 if 该怎么办。

最佳答案

这里没有异常:你的 else 语句对应于 a==b ;)

关于c - 为什么下面代码中C语言的else命令所在行没有被读取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36449837/

相关文章:

从 QueryPerformanceCounter() 计算周期/字节

c++ - 如何将 Visual Studio 用作可变长度数组 (VLA) 工作的 IDE?

c - 在 C 中运行多个递归函数

c - Speck Cipher - C 中的解密问题

c - 大小没有增加,但它存储了更大的数据。这怎么可能?

c - 哪个 for 循环更好?

c# - 如何使用 C# 或 C/C++ 在 Windows 7 中获取智能卡读卡器名称?

c - 使用 strchr() 从一个主字符串创建多个字符串

c - 如何使用此正则表达式避免 regcomp 错误 13?

在c中创建动态数组