本地数据全过了,但上传后都WA了,求助sos
查看原帖
本地数据全过了,但上传后都WA了,求助sos
223253
贾天翯楼主2021/11/12 19:07
#include<iostream>
#include<sstream>
#include<string>

using namespace std;

int main()
{
	int state=0;
	int n;
	string s,t;
	cin >> n;
	cin.ignore();
	while(n--)
	{
		getline(cin, s);
		stringstream ss(s),sss;
		int x, y;
		if (s[0]>='a'&&s[0]<='c')
		{
			ss >> t;				
			switch (s[0])
			{
			case 'a':
				state = 1; break;
			case 'b':
				state = 2; break;
			case 'c':
				state = 3; break;
			default:
				break;
			}
		}
		
		
		if (state == 1)
		{
			ss >> x, ss >> y;
			cout << x << '+' << y << '=' << x + y << endl;
			sss << x << y << x + y;
			sss >> t;
			cout << t.size() + 2;
			if(n!=0)	cout<<endl;
		}
		else if (state == 2)
		{
			ss >> x, ss >> y;
			cout << x << '-' << y << '=' << x - y << endl;
			sss << x << y << x - y;
			sss >> t;
			cout << t.size() + 2;
			if (n != 0)	cout << endl;
		}
		else if (state == 3)
		{
			ss >> x, ss >> y;
			cout << x << '*' << y << '=' << x * y << endl;
			sss << x << y << x * y;
			sss >> t;
			cout << t.size() + 2;
			if (n != 0)	cout << endl;
		}
	}
}
2021/11/12 19:07
加载中...