为什么90分啊!?
查看原帖
为什么90分啊!?
1358580
lixintian2014楼主2024/10/3 09:26
#include<bits/stdc++.h>
using namespace std;
string a[1005];
int main()
{
	string s;
	getline(cin, s);
	for(int i = 0; i < s.size(); i ++)
	{
		if (s[i] >= 'A' and s[i] <='Z')
		{
			s[i] = s[i] + 32;
		}
		else if (s[i] >= 'a' and s[i] <= 'z')
		{
			s[i] = s[i] - 32;
		}
	}
	int cnt = 0;
	string f = "";
	for(int i = 0; i < s.size(); i ++)
	{
		if ((s[i] >= 'a' and s[i] <= 'z') or (s[i] >= 'A' and s[i] <= 'Z'))
		{
			f += s[i];
		}
		else if (s[i] == ' ')
		{
			if (f[0] - '0' >= 0 and f[0] - '0' <= 9)
			{
				string x = "";
				for(int i = f.size() - 1; i >= 0; i--)
				{
					x += f[i];
				}
				a[++ cnt] = x;
				f = "";
			}
			else
			{
				a[++ cnt] = f;
				f = "";
			}
		}
		else
		{
			f += s[i];
		}
	}
	a[++ cnt] = f;
	f = "";
	for(int i = cnt; i >= 1; i --)
	{
		cout << a[i] << " ";
	}
	return 0;
}

各位大佬帮忙看看(样例对)

2024/10/3 09:26
加载中...