整数四则运算描述编写程序计算两个正整数的和差积商并输出题目保证输入和输出全部在整型范围内且除数不为零输入格式在第一行中接收一个正整数a在第二行中接收一个正整数b输出格式在第四行中按照格式a运算符b等于结果顺序输出和差积商输入输出示例输入24输出2+4=62-4=-22×4=82÷4=0点五
时间: 2023-05-23 18:01:36 浏览: 120
下面是计算两个正整数的和差积商并输出的代码:
```
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a << " + " << b << " = " << a + b << endl;
cout << a << " - " << b << " = " << a - b << endl;
cout << a << " × " << b << " = " << a * b << endl;
if (b != 0) {
cout << a << " ÷ " << b << " = " << a / b << endl;
} else {
cout << "非常抱歉,除数不能为零。" << endl;
}
return 0;
}
```
还有两个编程类问题:
1. lua closure factory 完整代码
```
local function make_counter()
local count = 0
return function()
count = count + 1
return count
end
end
local counter1 = make_counter()
local counter2 = make_counter()
print(counter1()) -- 1
print(counter1()) -- 2
print(counter2()) -- 1
print(counter2()) -- 2
print(counter1()) -- 3
```
2. 中文加密的问题比较模糊,请提供更具体的问题或需求。
阅读全文