qfedu-basic-level/day6/homework/h5.cpp

15 lines
279 B
C++
Raw Permalink Normal View History

#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;
}