题解 | #字符串操作#
字符串操作
https://www.nowcoder.com/practice/06a5336b64e3481fbbcc1f7d5cba548d
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); char arr[a + 1]; scanf("%s", arr); int arr1[4]; for (int i = 0; i < b; i++) { for (int n = 0; n < 4; n++) { if (n < 2) scanf("%d", arr1 + n); else { getchar(); arr1[n] = getchar(); } } for (int j = arr1[0] - 1; j < arr1[1]; j++) { if (arr[j] == arr1[2]) { arr[j] = arr1[3]; } } } printf("%s\n", arr); return 0; }