输入两个数,如果它们都是正数,输出它们的和;如果它们都是负数,输出它们的积;否则输出它们的差。
This commit is contained in:
parent
ffb080d49f
commit
8401248063
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue