输入 | 输出 |
1 2 1 abcs-w1234-9s-4zz |
abcsttuuvvw1234556677889s-4zz |
输入 | 输出 |
2 3 2 a-d-d |
aCCCBBBd-d |
输入 | 输出 |
3 4 2 di-jkstra2-6 |
dijkstra2************6 |
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() { 4 int p1, p2, p3; 5 string s; 6 cin >> p1 >> p2 >> p3 >> s; 7 for (int i = 0; i < s.size(); i++) { 8 cout << s[i]; 9 if (i < s.size() - 2 && s[i + 1] == ‘-‘ && 10 ((isdigit(s[i]) && isdigit(s[i + 2])) || (islower(s[i]) && islower(s[i + 2])))) { 11 char c1 = s[i], c2 = s[i + 2]; 12 string ans = ""; 13 if (c1 >= c2) { 14 ans = "-"; 15 } else if (c1 + 1 == c2) { 16 ans = ""; 17 } else { 18 if (p3 == 1) { 19 for (int i = c1 + 1; i < c2; i++) { 20 if (p1 == 1) { 21 ans.append(p2, tolower((char) i)); 22 } 23 if (p1 == 2) { 24 ans.append(p2, toupper((char) i)); 25 } 26 if (p1 == 3) { 27 ans.append(p2, ‘*‘); 28 } 29 } 30 } 31 if (p3 == 2) { 32 for (int i = c2 - 1; i > c1; i--) { 33 if (p1 == 1) { 34 ans.append(p2, tolower((char) i)); 35 } 36 if (p1 == 2) { 37 ans.append(p2, toupper((char) i)); 38 } 39 if (p1 == 3) { 40 ans.append(p2, ‘*‘); 41 } 42 } 43 } 44 } 45 cout << ans; 46 i++; 47 } 48 } 49 return 0; 50 }
原文:https://www.cnblogs.com/fx1998/p/12662785.html