40pts HELP!!!!!!!!!!!!!!!!!
查看原帖
40pts HELP!!!!!!!!!!!!!!!!!
1390387
vector_STL_楼主2024/11/1 22:47
#include <iostream>
#include <string>
using namespace std;

int shuwei(int a) {
	int r = 0;
	while (a != 0) {
		r++;
		a /= 10;
	}
	return r;
}
char a;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b, c;
		if (i == 0) {
			cin >> a >> b >> c;
		} else {
			if (!(cin >> b >> c)) {
				cin >> a >> b >> c;
			}
		}
		if (a == 'a') {
			cout << b << "+" << c << "=" << b + c << endl;
			cout << shuwei(b) + shuwei(c) + shuwei(b + c) + 2 << endl;
		}
		else if (a == 'b') {
			cout << b << "-" << c << "=" << b - c << endl;
			if (b - c < 0) {
				cout << shuwei(b) + shuwei(c) + shuwei(b - c) + 3 << endl;
			} else {
				cout << shuwei(b) + shuwei(c) + shuwei(b - c) + 2 << endl;
			}
		}
		else if (a == 'c') {
			cout << b << "*" << c << "=" << b *c << endl;
			cout << shuwei(b) + shuwei(c) + shuwei(b * c) + 2 << endl;
		}
		
	}
}
2024/11/1 22:47
加载中...