离奇MLE
码:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int p1, p2, p3;
string s, temp;
bool check(int x)//判断s[x]是否满足展开条件(s[x]为'-')
{
if (islower(s[x - 1]) && islower(s[x + 1]) && s[x - 1] < s[x + 1])//小写字母
{
return true;
}
if (isdigit(s[x - 1]) && isdigit(s[x + 1]) && s[x - 1] < s[x + 1])//数字
{
return true;
}
return false;
}
int main()
{
cin >> p1 >> p2 >> p3 >> s;
for (int i = 1; i < s.size() - 1; i++)//s[0]和s[s.size()-1]跳过
{
if (s[i] == '-' && check(i))//满足展开条件
{
s.erase(s.begin() + i);//删除'-'
temp = "";
if (p1 == 3)//无论s[x-1]和s[x+1]是字母还是数字
{
for (int j = s[i - 1] + 1; j < s[i]; j++)
{
for (int k = 1; k <= p2; k++)
{
temp += '*';
}
}
}
else
{
if (isdigit(s[i - 1]))//数字
{
for (int j = s[i - 1] + 1; j < s[i]; j++)
{
for (int k = 1; k <= p2; k++)
{
temp += j;
}
}
}
else
{
if (p1 == 1)//填充小写字母
{
for (int j = s[i - 1] + 1; j < s[i]; j++)
{
for (int k = 1; k <= p2; j++)
{
temp += j;
}
}
}
if (p1 == 2)//填充大写字母
{
for (int j = s[i - 1] + 1; j < s[i]; j++)
{
for (int k = 1; k <= p2; k++)
{
temp += toupper(j);//小写转大写
}
}
}
}
}
if (p3 == 2)//需要翻转
{
reverse(temp.begin(), temp.end());
}
s.insert(i, temp);//插回s
}
}
cout << s << endl;
return 0;
}