#include <stdio.h> int main() { int n, m;//字符数,行数 int l, r;//选取范围 int i = 0; char s[1000] = {0}, c1, c2; scanf("%d %d", &n, &m);//输入 scanf("%s", s); for (i = 0; i < m; i++) { //根据m值进行循环 scanf("%d %d %c %c", &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; }