bdcml @ 2023-01-14 13:32:06
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,i,n,m,a,b,c;
cin>>i;
char q[20],p[i+1];
int aa[i],bb[i],cc[i],w[i];
for(n=1;n<=i;n++){
w[n]=2;
cin>>q;
if(isalpha(q[0])){
p[n]=q[0];
cin>>a>>b;
}
else{
a=atoi(q);
cin>>b;
p[n]=p[n-1];
}
if(p[n]=='a') m=a+b;
else if(p[n]=='b') m=a-b;
else if(p[n]=='c') m=a*b;
aa[n]=a;
bb[n]=b;
cc[n]=m;
if(a<=0){
a*=-1;
w[n]++;
}
if(b<=0){
b*=-1;
w[n]++;
}
if(m<=0){
m*=-1;
w[n]++;
}
while(a>=1){
a=a/10;w[n]++;
}
while(b>=1){
b=b/10;w[n]++;
}
while(m>=1){
m=m/10;w[n]++;
}
}
for(n=1;n<=i;n++){
cout<<aa[n];
if(p[n]=='a') cout<<"+";
else if(p[n]=='b') cout<<"-";
else if(p[n]=='c') cout<<"*";
cout<<bb[n]<<"="<<cc[n];
cout<<endl<<w[n]<<endl;
}
return 0;
}
by Battle_Maple @ 2023-01-19 09:16:37
我是2 8错,晕