Compile Error
查看原帖
Compile Error
805551
scj_juruo楼主2022/10/16 20:35

rt,代码如下

#include <bits/stdc++.h>
using namespace std;
int t,n1,n2;
char op;
int main()
{
	cin>>t;
	while(t--)
	{
		string tmp;
		cin>>tmp;
		if(tmp[0]>='a'&&tmp[0]<='c')
		{
			op=tmp[0];
			cin>>n1>>n2;
		}
		else
		{
			sscanf(tmp.c_str(),"%d",n1);
			cin>>n2;
		}
		string x="";
		if(op=='a')
			sprintf(x.c_str(),"%d+%d=%d\n",n1,n2,n1+n2);
		else if(op=='b')
			sprintf(x.c_str(),"%d-%d=%d\n",n1-n2,n1-n2);
		else if(op=='c')
			sprintf(x.c_str(),"%d*%d=%d\n",n1,n2,n1*n2);
		cout<<x<<x.length()<<endl;
	}
	return 0;
}

2022/10/16 20:35
加载中...