题解 | 最大最小值

最大最小值

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

#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    // 确定最大值
    int max_num = a;
    if (b > max_num) max_num = b;
    if (c > max_num) max_num = c;

    // 确定最小值
    int min_num = a;
    if (b < min_num) min_num = b;
    if (c < min_num) min_num = c;

    // 统一输出
    cout << "The maximum number is : " << max_num << endl;
    cout << "The minimum number is : " << min_num << endl;

    return 0;
}

全部评论

相关推荐

安静的鲸鱼offer...:神仙级别hr,可遇不可求,甚至他可能也是突然有感而发。只能说遇上是件幸事。
秋招开始捡漏了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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