#include <bits/stdc++.h>
#include <windows.h>
#include <iomanip>
using namespace std;
int main() {
cout << "\033[34;1m";
cout << "\033[34;1m";
long long a, b, d, m = 1, ew = 0;
long long jc;
string da = " ";
int ak;
char c;
string o;
do {
system("cls");
if (ew == 1) {
cout << "上次寄存的答案";
cout << da << endl;
}
ew = 0;
cout << "输入算式" << endl;
cin >> a >> c >> b ;
system("cls");
if (c == '|')
if (a < 0) {
cout << a * -1 << endl;
} else {
cout << a;
}
if (c == '/') {
cout << "1.小数结果/2.余法运算" << endl;
cin >> d;
if (d == 1) {
system("cls");
cout << "那么你想保留几位小数呢?" << endl;
cin >> ak;
system("cls");
cout << "答案:" << fixed << setprecision(a) << (a + 0.00) / b << endl;
} else {
system("cls");
cout << "答案:" << a / b << "------" << a % b << endl;
}
}
if (c == '*')
cout << "答案:" << a *b << endl;
if (c == '-')
cout << "答案:" << a - b << endl;
if (c == '+')
cout << "答案:" << a + b << endl;
if (c == 'e') {
for (int i = 1; i <= b; i++)
m *= a;
cout << "答案:" << m << endl;
}
cout << "请输入要寄存的答案:" << endl;
cout << "跳过:f、F" << endl;
cin >> da;
if (da != "f" && da != "F")
ew = 1;
system("cls");
cout << "是否再次使用此工具?" << endl;
cin >> o;
} while (o == "t");
system("cls");
cout << "欢迎再次使用此工具!";
return 0;
}
计算器(一个四年级小朋友编出来的)
最新推荐文章于 2024-10-04 17:07:53 发布