输入两个数,如果它们都是正数,输出它们的和;如果它们都是负数,输出它们的积;否则输出它们的差。

This commit is contained in:
flykhan 2023-06-20 08:50:11 +08:00
parent ffb080d49f
commit 8401248063
1 changed files with 15 additions and 0 deletions

15
day6/homework/h5.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main()
{
int a, b;
int outnum; // 输出的数字
cout << "请输入两个整数: ";
cin >> a >> b;
outnum = a > 0 ? (b > 0 ? a + b : a - b) : (b < 0 ? a * b : a - b);
cout << outnum << endl;
return 0;
}