题解 | #字符串操作#
字符串操作
http://www.nowcoder.com/practice/06a5336b64e3481fbbcc1f7d5cba548d
int main() {
int n, m, l, r;
char s[1000] = {0}, c1, c2;
scanf("%d %d\n%s", &n, &m, &s);
for (int i = 0; i < m; i++) { //根据m值进行循环
scanf("%d %d %c %c\n", &l, &r, &c1, &c2);
for (int j = l; j <= r; j++) { //根据每次输入的l,r值进行循环
if (s[j - 1] == c1) s[j - 1] = c2; //根据c1,c2的值来进行修改
}
}
printf("%s", s); //输出最终结果
return 0;
}