符棱862 @ 2021-02-07 12:05:56
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int n;
char f='\0';
scanf("%d",&n);
getchar();
while(n--)
{
int x,y,z=0,sum=0;
char s[1000]="\0",line[1000]="\0";
gets(s);
if(s[0]=='a') z=1,f='+';
else if(s[0]=='b') z=1,f='-';
else if(s[0]=='c') z=1,f='*';
if(z) sscanf(s+1,"%d%d",&x,&y);
else sscanf(s,"%d%d",&x,&y);
if(f=='+') sum=x+y;
else if(f=='-') sum=x-y;
else if(f=='*') sum=x*y;
sprintf(line,"%d%c%d=%d",x,f,y,sum);
printf("%s\n%d\n",line,strlen(line));
}
return 0;
}
by baiABC @ 2021-02-07 12:14:51
去 洛谷在线IDE
by 符棱862 @ 2021-02-07 12:43:00
感谢,找到错误点了