fff1842889002 @ 2022-03-06 17:53:17
#include<bits/stdc++.h>
using namespace std;
string a1,a2,a3;
string b;
int ans,e1,e2;
int h;
int main()
{
int a;
scanf("%d",&a);
for(int i=0;i<a;i++)
{
a1="!",a2="!",a3="!";
scanf("%s %s %s",&a1,&a2,&a3);
if(a3[0]=='!') a3=a2,a2=a1;
b=a1;
h=a1.length()+a2.length()+a3.length();
for(int j=a2.length();j>0;j++)
e1+=(a2[i]-'0')*pow(10,j-1);
for(int j=a3.length();j>0;j++)
e2+=(a3[i]-'0')*pow(10,j-1);
if(b[0]=='a')
ans=e1+e2,printf("%d %d=%d/n%d/n",e1,+e2,ans,h);
if(b[0]=='b')
ans=e1-e2,printf("%d %d=%d/n%d/n",e1,-e2,ans,h);
if(b[0]=='c')
ans=e1*e2,printf("%d*%d=%d/n%d/n",e1,e2,ans,h);
}
return 0;
}
by tin_ingot @ 2022-03-06 18:04:11
@fff1842889002 scanf不能直接输入字符串,只能这样:scanf("%s %s %s",a1.c_str(),a2.c_str(),a3.c_str());
by STLvector @ 2022-03-06 18:14:39
@滑稽人
cin>>a1>>a2>>a3
scanf的%s需要预先分配空间
by tin_ingot @ 2022-03-06 18:15:24
@ConsleStick 嗯