21 lines
429 B
C++
21 lines
429 B
C++
// 测试多分支结构
|
|
#include <iostream>
|
|
#include <cmath> // c++ 数学库: 提供 abs() 函数
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
cout << "请输入2个数: ";
|
|
int a, b;
|
|
cin >> a >> b;
|
|
|
|
if (a >= 0 && b >= 0)
|
|
cout << "a + b = " << a + b << endl;
|
|
else if (a < 0 && b < 0)
|
|
cout << "a * b = " << a * b << endl;
|
|
else
|
|
{
|
|
cout << "a 和 b 差值: " << abs(a - b) << endl;
|
|
}
|
|
} |