计算器(一个四年级小朋友编出来的)

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值