dp_hater @ 2022-07-14 16:19:57
本地运行全对,下载了测试点之后也每看出什么问题 输入:
1
a 99 999
输出:
99+999=1098
11
#include<bits/stdc++.h>
using namespace std;
char l,s[105],ans[105];
int main(){
int n,a,b,c;
cin>>n;
cin.ignore();
for(int i=0;i<n;i++){
fgets(s,sizeof(s),stdin);
if(s[0]>='a'&&s[0]<='c') l=s[0],s[0]=' ';
sscanf(s,"%d %d",&a,&b);
switch(l){
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;
}
cout<<ans<<endl<<strlen(ans)<<endl;
}
return 0;
}
by LiaoYF @ 2022-07-14 16:32:18
@xmyzJerryczr 你输入输出好奇怪,我看了,第1行是空行,应该就是这个导致WA,你把输入输出换成cin
cout
或者scanf
printf