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