提交时间:2023-08-22 11:23:14
运行 ID: 99167
#include <bits/stdc++.h> using namespace std; int p1, p2, p3, cur=0; string s; char res[1005]; void putChar(char c) { for (int i = 1; i <= p2; i++) { if (p1 == 3) res[cur++] = '*'; else if (p1 == 2 && 'a' <= c && c <= 'z') res[cur++] = c - 'a' + 'A'; else res[cur++] = c; } } void decode2(char s, char e) { for (char i = e-1; i >= s+1; i--) { putChar(i); } } void decode1(char s, char e) { for (char i = s+1; i <= e-1; i++) { putChar(i); } } void decode(char s, char e) { if (s == e) { res[cur++] = '-'; } else if (p3 == 2) { decode2(s, e); } else { decode1(s, e); } } void check(int pos) { if (pos == 0 || pos == s.size() - 1) { res[cur++] = s[pos]; } else if (s[pos] == '-') { if ('0' <= s[pos-1] && s[pos-1] <= '9' && '0' <= s[pos+1] && s[pos+1] <= '9') decode(s[pos-1], s[pos+1]); else if ('a' <= s[pos-1] && s[pos-1] <= 'z' && 'a' <= s[pos+1] && s[pos+1] <= 'z') decode(s[pos-1], s[pos+1]); else res[cur++] = s[pos]; } else res[cur++] = s[pos]; } int main() { cin >> p1 >> p2 >> p3; cin >> s; for (int i=0; i < s.size(); i++) { check(i); } cout << res << endl; return 0; }