finalSTian @ 2022-12-06 22:34:49
#include <bits/stdc++.h>
using namespace std;
const int N=55;
char str[20],ans[20];
int n;
char op;
int main(){
scanf("%d",&n);
getchar();
for(int i=1;i<=n;i++){
fgets(str,sizeof str,stdin);
if(str[0]=='a'||str[0]=='b'||str[0]=='c'){
op=str[0];
str[0]=' ';
}
int a=0,b=0,c=0;
sscanf(str,"%d %d",&a,&b);
if(op=='a'){
sprintf(ans,"%d+%d=%d",a,b,c=a+b);
}
else if(op=='b'){
sprintf(ans,"%d-%d=%d",a,b,c=a-b);
}
else{
sprintf(ans,"%d*%d=%d",a,b,c=a*b);
}
printf("%s\n%d\n",ans,strlen(ans));
}
return 0;
}
by finalSTian @ 2022-12-06 23:08:34
找出来了 我用的getchar()来处理缓冲区中回车的问题,但似乎洛谷ide不能这样
by suchachaos @ 2022-12-23 11:06:36
@shangtian551 不是不能,是要用两个getchar(),这个评测环境中行末换行是/r/n两个字符