T_TLucas_Yin @ 2023-06-16 17:30:36
#include<bits/stdc++.h>
using namespace std;
int n;
string a,b,c;
int f(string s){
int cnt=0;
for(int i=0;i<s.size();i++) cnt=cnt*10+(s[i]-'0');
return cnt;
}
int f1(int x){
int cnt=0;
if(x<0) cnt++;
while(x!=0) x/=10,cnt++;
return cnt;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>b;
if(b=="a"||b=="b"||b=="c"){
a=b;
cin>>b>>c;
}
else cin>>c;
int x=f(b),y=f(c);
if(a=="a") printf("%d+%d=%d\n%d\n",x,y,x+y,f1(x)+f1(y)+f1(x+y)+2);
if(a=="b") printf("%d-%d=%d\n%d\n",x,y,x-y,f1(x)+f1(y)+f1(x-y)+2);
if(a=="c") printf("%d*%d=%d\n%d\n",x,y,x*y,f1(x)+f1(y)+f1(x*y)+2);
}
return 0;
}
by 天南星魔芋 @ 2023-06-16 17:37:28
@T_TLucas_Yin 如果运算结果为零就错了吧
by T_TLucas_Yin @ 2023-06-16 17:43:16
@天南星魔芋 感谢大佬