题解 | 最大最小值

最大最小值

https://www.nowcoder.com/practice/051cbca4504d40f5b20bb891d83ec408

#include <stdio.h>

int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int temp;

    if(a>b)//确保a的值小于b
    {
    temp = a;
    a = b;
    b = temp;
    }
    if(a>c)//确保a的值最小
    {
        temp = a;
        a = c;
        c = temp;
    }
    if(b>c)//确保b的值小于c
    {
        temp = b;
        b = c;
        c = temp;
    }
    printf("The maximum number is : %d\n",c);//一般不要忘了'\n'
    printf("The minimum number is : %d\n",a);
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务