jk47 @ 2021-11-13 15:45:37
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
char a[100],ans[100];
char last;
int b,c,n;
cin>>n;
getchar();
while(n--)
{
fgets(a,sizeof(a),stdin);
if(a[0]=='a'||a[0]=='b'||a[0]=='c')
{ last=a[0];
a[0]=' ';
}
sscanf(a,"%d %d",&b,&c);
switch(last)
{
case 'a' : sprintf(ans,"%d+%d=%d",b,c,b+c);break;
case 'b' : sprintf(ans,"%d-%d=%d",b,c,b-c);break;
case 'c' : sprintf(ans,"%d*%d=%d",b,c,b*c);break;
}
printf("%s\n%d",ans,strlen(ans));
if(n!=0)
printf("\n");
}
return 0;
}
by xingyl @ 2021-11-18 17:09:23
好像是洛谷编辑器的问题,我的也是这种情况,在洛谷的ide上一跑样例都过不了。