You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
//批量输出某个字符
|
|
|
|
|
void print(char c, int cnt) {
|
|
|
|
|
for (int i = 1; i <= cnt; i++) cout << c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int p1; //大写小写还是星号 1:小写 2:大写 3:星号
|
|
|
|
|
int p2; //个数 连续填充的个数
|
|
|
|
|
int p3; //是否改为逆序:p3=1表示维持原来顺序,p_3=2表示采用逆序输出
|
|
|
|
|
|
|
|
|
|
string s;
|
|
|
|
|
cin >> p1 >> p2 >> p3 >> s;
|
|
|
|
|
//找到所有的-号
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
//遇到下面的情况需要做字符串的展开:在输入的字符串中,
|
|
|
|
|
// 出现了减号“-”,减号两侧同为小写字母或同为数字,且按照ASCII码的顺序,
|
|
|
|
|
// 减号右边的字符严格大于左边的字符
|
|
|
|
|
|
|
|
|
|
if (s[i] == '-' && ((isdigit(s[i - 1]) && isdigit(s[i + 1])) || (isalpha(s[i - 1]) && isalpha(s[i + 1])))) {
|
|
|
|
|
//减号右边的字符严格大于左边的字符
|
|
|
|
|
if (s[i - 1] < s[i + 1]) {
|
|
|
|
|
//输出*号
|
|
|
|
|
if (p1 == 3) // p_1=3时,不论是字母子串还是数字字串,
|
|
|
|
|
// 都用与要填充的字母个数相同的星号“*”来填充。
|
|
|
|
|
//注意填充的字符是两边不咬~
|
|
|
|
|
for (char a = s[i - 1] + 1; a < s[i + 1]; a++) print('*', p2);
|
|
|
|
|
//小写
|
|
|
|
|
if (p1 == 1) {
|
|
|
|
|
if (p3 == 1) //原序
|
|
|
|
|
for (char a = s[i - 1] + 1; a < s[i + 1]; a++) print(tolower(a), p2);
|
|
|
|
|
else //倒序
|
|
|
|
|
for (char a = s[i + 1] - 1; a > s[i - 1]; a--) print(tolower(a), p2);
|
|
|
|
|
}
|
|
|
|
|
//大写
|
|
|
|
|
if (p1 == 2) {
|
|
|
|
|
if (p3 == 1) //原序
|
|
|
|
|
for (char a = s[i - 1] + 1; a < s[i + 1]; a++) print(toupper(a), p2);
|
|
|
|
|
else //倒序
|
|
|
|
|
for (char a = s[i + 1] - 1; a > s[i - 1]; a--) print(toupper(a), p2);
|
|
|
|
|
}
|
|
|
|
|
} //否则给啥就输出啥
|
|
|
|
|
else
|
|
|
|
|
print(s[i], 1);
|
|
|
|
|
}
|
|
|
|
|
//输出正常的字符
|
|
|
|
|
else
|
|
|
|
|
print(s[i], 1);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|