90分,#10WA求调
查看原帖
90分,#10WA求调
1047861
hzx3222010楼主2024/10/25 09:15
#include<bits/stdc++.h>
using namespace std;
int sw(int x,int y,int z){
	int ans=0;
	if(x<=0) ans++;
	if(y<=0) ans++;
	if(z<=0) ans++;
	while(x) x/=10,ans++;
	while(y) y/=10,ans++;
	while(z) z/=10,ans++;
	return ans;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		char a,d;
		int b,c;
		d=a;
		cin>>a;
		cin>>b>>c;
		if('0'<=a&&a<='9'){
			int e=b,ans=0;
			while(e) e/=10,ans++;
			int f=a-'0';
			b+=f*(pow(10,ans));
			a=d;
		}
		cout<<b;
		if(a=='a'){
			cout<<'+'<<c<<'='<<b+c<<endl;
			cout<<sw(b,c,b+c)+2<<endl;
		}
		else if(a=='b'){
			cout<<'-'<<c<<'='<<b-c<<endl;	
			cout<<sw(b,c,b-c)+2<<endl;
		}
		else{
			cout<<'*'<<c<<'='<<b*c<<endl;	
			cout<<sw(b,c,b*c)+2<<endl;
		}
	}
	return 0;
}
2024/10/25 09:15
加载中...