"Idea": follow the test instructions to the line. Note the difference between the letter string and the number string when p1=2. It is recommended to use a string, replacing the line with the Replace function, char[] to move large amounts of data.
"AC Code":
#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include < cstring>using namespace std; #define MAX 10000+5int Islower (char c) {if (C >= ' a ' && c <= ' z ') return 1;retu RN 0;} int Isnum (char c) {if (c >= ' 0 ' && C <= ' 9 ') return 1;return 0;} void reverse (char repstr[]) {int i = 0;for (i = 0; i < strlen (REPSTR)/2; i++) {char temp;temp = repstr[i];repstr[i] = Rep Str[strlen (REPSTR) -1-i];repstr[strlen (repstr) -1-i] = temp;}} int main () {freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout); int p1 = 0, p2 = 0, p3 = 0, i = 0, j = 0, k = 0;s Tring str;//inputcin >> p1 >> p2 >> p3;cin >> str;//handlefor (i = 1; i < str.length () 1; i++) Note Scope {if ('-' = ' = Str[i]) {int flag = 0;char repstr[max];if (islower (str[i-1]) && islower (str[i+1]) && str [i+1]>str[i-1]) flag = 1;else if (Isnum (str[i-1]) && isnum (str[i+1]) && str[i+1]>str[i-1]) flag = 2; if (0==FLAG) continue;//replace p1 p2 int cnt = 0;for (j = str[i-1]+1; J < str[i+1]; J + +) {for (k = 0; k < P2; k++) {if (1 = = p1) {Repst r[cnt++] = j;} else if (2 = = p1) {if (1 = = flag) repstr[cnt++] = j+ ' A '-' a '; else if (2 = = flag) repstr[cnt++] = j;} else if (3 = = p1) {repstr[cnt++] = ' * ';}}} REPSTR[CNT] = ' + ';//p3if (2 = = p3) reverse (REPSTR);//replacestring rep = Repstr;str.replace (i, 1, Rep);}} Outputcout << Str;return 0;}
Note:
Common functions of the 1.c++string class
2. Conversion between string and char* char[]
Blue Bridge Cup ALGO-110 string expansion (String)