90分第九个没过
查看原帖
90分第九个没过
1474086
ILLENIAL725楼主2024/12/18 16:37
#include<iostream>
#include<vector>
#include<cctype>
#include<string>
#include<algorithm>

using namespace std;

int main()
 {
	int p1, p2, p3;
	string s;
	string res;
	cin >> p1 >> p2 >> p3 >> s;
	s=" "+s+" ";
	for (int i = 1; i < s.size(); i++)
	{
		if (s[i] == '-' && s[i - 1] == '-')
		{
			s.erase(i, 1);
			i--;
		}
	}
	size_t pos = s.find('-');
	while (pos != string::npos)
	{
		res += s.substr(0, pos );
		
		if (s[pos + 1] <= s[pos - 1])
		{
			res = res + s[pos] ;
		}
		else if (s[pos + 1] == s[pos - 1] + 1)
		{
		}
		else
		{
			string tem;
			if ((isalpha(s[pos - 1]) && isalpha(s[pos + 1]))||(isdigit(s[pos - 1]) && isdigit(s[pos + 1])))
			{
				if (p1 == 1)
				{
					for (char ch = s[pos - 1] + 1; ch < s[pos + 1]; ch++)
					{
						for (int i = 1; i <= p2; i++)
						{
							tem += tolower(ch);
						}
					}

				}
				else if (p1 == 2)
				{
					for (char ch = s[pos - 1] + 1; ch < s[pos + 1]; ch++)
					{
						for (int i = 1; i <= p2; i++)
						{
							tem += toupper(ch);
						}
					}
				}
				else if (p1 == 3)
				{
					for (char ch = s[pos - 1] + 1; ch < s[pos + 1]; ch++)
					{
						tem += '*';
					}
				}
			}
			else
			{
				tem = "-";
			}
			if (p3 == 2)
			{
				reverse(tem.begin() , tem.end() );
			}
			res += tem;
		}
		s = s.substr(pos + 1);
		pos = s.find('-');
	}
	res += s;
	res.erase(0, 1);
	res.erase(res.size() - 1, 1);
	cout << res << endl;
	return 0;
}
2024/12/18 16:37
加载中...