Milonia @ 2023-09-19 13:59:21
#include <iostream>
using namespace std;
int n,a,b,k,k1;
char c;
int mode;
void jkl(int a,int b,int ans){
int num;
if (a==0) num++;
if (b==0) num++;
while (a>0) {
a/=10;
num++;
}
while (b>0) {
b/=10;
num++;
}
if (ans==0) num++;
else if (ans>0) {
while (ans>0) {
ans/=10;
num++;
}
} else {
num++;
ans*=-1;
while (ans>0) {
ans/=10;
num++;
}
}
printf("%d\n",num+2);
return;
}
int main(){
cin>>n;
while (n--) {
cin>>c;
if (c=='a' || c=='b' || c=='c'){
cin>>a>>b;
if (c=='a') mode=1;
else if (c=='b') mode=2;
else if (c=='c') mode=3;
} else {
a=c-'0';
//cout<<a<<"##"<<endl;
cin>>k>>b;
k1=k;
int cnt=0;
while (k>0) {
k/=10;
cnt++;
}
while (cnt--) a*=10;
a+=k1;
}
int ans=0;
if (mode==1) {
ans=a+b;
printf("%d+%d=%d\n",a,b,ans);
jkl(a,b,ans);
} else if (mode==2) {
ans=a-b;
printf("%d-%d=%d\n",a,b,ans);
jkl(a,b,ans);
} else if (mode==3) {
ans=a*b;
printf("%d*%d=%d\n",a,b,ans);
jkl(a,b,ans);
}
}
return 0;
}
第一个数据是 1 a 99 999
输出的也没问题 但是一提交就是WA