题解 | #简单运算#
简单运算
https://www.nowcoder.com/practice/23c9b22d40fa4d7698a1306fb0c9f975
#include <iostream>
using namespace std;
int main() {
int a, b;
// 输入两个整数
std::cin >> a >> b;
// 计算和、差、积、商、模
int sum = a + b;
int difference = (a > b) ? (a - b) : (b - a);
int product = a * b;
int quotient = (a > b) ? (a / b) : (b / a);
int remainder = (a > b) ? (a % b) : (b % a);
// 输出结果
std::cout << sum <<" " << difference << " " << product << " " << quotient << " " << remainder << " " << std::endl;
return 0;
}
查看3道真题和解析