XSean @ 2022-08-16 18:15:46
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
char a[3];
int x,y;
char s[1001]={};
for(int i=1;i<=n;i++){
cin>>a;
char a1;
if(a[0]>='a'&&a[0]<='c'){
a1=a[0];
cin>>x>>y;
}else{
x=atoi(a);
cin>>y;
}
memset(s,0,sizeof(s));
if(a1=='a'){
sprintf(s,"%d+%d=%d",x,y,x+y);
}else if(a1=='b'){
sprintf(s,"%d-%d=%d",x,y,x-y);
}else{
sprintf(s,"%d*%d=%d",x,y,x*y);
}
cout<<s<<endl<<strlen(s)<<endl;
}
return 0;
}
by C201529 @ 2022-08-16 19:25:55
@Sean_xzx
仔细看题:
运算数为非负整数且小于 '\0'
看见了记得回复一下
by XSean @ 2022-08-16 21:01:12
@C201529 谢谢了