20250225-Rain

1. 判断

/*
1.
设计一个程序, 输入a,b,c三个整数, 输出最大的数.
(MIN_INT < a,b,c < MAX_INT)
*/

#include <iostream>

using namespace std;

int m_max(int x, int y);

int main(void)
{
    int a, b, c;
    int res;
    cout << "Please input 'a' 'b' 'c'(space to separate): " << endl;
    cin >> a >> b >> c;

    // 依次比较最大值
    res = m_max(m_max(a, b), c);
    cout << "The max number is:" << res << endl;
    return 0;
}

// 可以自定义比较函数
int m_max(int x, int y)
{
    return x > y ? x : y;
}

也可以使用 C++ 内置的 max() 函数,效果一致

2. 嵌套循环

3. 简单循环

注意距离的计算包括 下降距离 和 回弹后上升距离

Last updated