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