guoyanwei120223 @ 2024-08-24 16:51:55
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,n;
char last,s[20],ans[20];
scanf("%d",&n);
getchar();
while(n--)
{
fgets(s,sizeof(s),stdin);
if(s[0]=='a'||s[0]=='b'||s[0]==c)
{
last=s[0];
s[0]=' ';
}
sscanf(s,"%d %d",&a,&b);
switch(last)
{
case 'a':c=a+b;sprintf(ans,"%d+%d=%d",a,b,c);break;
case 'b':c=a-b;sprintf(ans,"%d-%d=%d",a,b,c);break;
case 'c':c=a*b;sprintf(ans,"%d*%d=%d",a,b,c);break;
}
printf("%s\n%d\n",ans,strlen(ans));
}
}
by guoyanwei120223 @ 2024-08-24 16:57:07
@guoyanwei120223 好了,没事了,忘记加单引号了