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;
}2. 嵌套循环
3. 简单循环
Last updated