题解 | #字符串操作#
字符串操作
https://www.nowcoder.com/practice/06a5336b64e3481fbbcc1f7d5cba548d
#include <stdio.h> #define MAXSIZE 100 int main() { int n=0; int m=0; scanf("%d%d", &n, &m); char arr[MAXSIZE]; getchar(); gets(arr); int l=0; int r=0; char c1='0'; char c2='0'; while(m--) { scanf("%d %d", &l, &r); getchar(); scanf("%c", &c1); getchar(); scanf("%c", &c2); int j = 0; for (j = l - 1; j < r; j++) { if (arr[j] == c1) { arr[j] = c2; } } } puts(arr); return 0; }