#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/