LiJinLin_AFO @ 2023-03-28 21:08:46
#include<stdio.h>
#include<iostream>
using namespace std;
char a[25];
int cao(int n){
int ans=0;
if(n<0) n*=-1;
if(!n) ans=1;
while(n) ans++,n/=10;
return ans;
}
int main(){
register int t;
scanf("%d",&t);
t=t+1;
while(t--){
cin.getline(a,25);
int x=0,y=0;char w='e';
if(a[0]>='0'&&a[0]<='9'){
int i=0;
for(;a[i]!=' ';i++) x=x*10+a[i]-'0';
i++;
for(;a[i]!='\0';i++) if(a[i]!='\n') y=y*10+a[i]-'0';
}
else{
int i=2;w=a[0];
for(;a[i]!=' ';i++) x=x*10+a[i]-'0';
i++;
for(;a[i]!='\0';i++) if(a[i]!='\n') y=y*10+a[i]-'0';
}
if(w=='e'||w=='a') printf("%d+%d=%d\n%d\n",x,y,x+y,cao(x)+2+cao(y)+cao(x+y));
if(w=='b') printf("%d-%d=%d\n%d\n",x,y,x-y,cao(x)+cao(y)+2+(x-y<0?cao(x-y)+1:cao(x-y)));
if(w=='c') printf("%d*%d=%d\n%d\n",x,y,x*y,cao(x)+cao(y)+2+cao(x*y));
}return 0;
}
全RE了,怎么回事?