有3个整数a, b, c,由键盘输入,输出其中最大的数


有3个整数a, b, c,由键盘输入,输出其中最大的数

点我看视频讲解+可运行代码,记得收藏视频,一键三连
解题思路: 每个数字两两与剩余两个数字进行比较,若比剩下的两个数大则最大,例如:a>b && a>c则a是最大的

答案:

#include <stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b && a == c) {
        printf("Three numbers are equal\n");
    }else if (a == b && a > c) {
        printf("a and b are the largest number\n", a); 
    }else if (a == c && a > b) {
        printf("a and c are the largest number\n", a); 
    }else if (b == c && b > a) {
        printf("c and b are the largest number\n", a); 
    }else if (a > b && a > c) {
        printf("a=%d is the largest number\n", a); 
    }else if (b > a && b > c) {
        printf("b=%d is the largest number\n", b); 
    }else {
        printf("c=%d is the largest number\n", c); 
    }   
    return 0;
}

有3个整数a, b, c,由键盘输入,输出其中最大的数


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM