题解 | #字符串操作#
字符串操作
https://www.nowcoder.com/practice/06a5336b64e3481fbbcc1f7d5cba548d
#include <stdio.h>
#include <stdlib.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
char* str=malloc(sizeof(char)*a+1);
scanf("%s",str);
int x,y,i;
char m,n;
while(~scanf("%d %d %c %c",&x,&y,&m,&n))
{
for(i=x-1;i<y;i++)
{
if(*(str+i)==m)
*(str+i)=n;
}
}
printf("%s\n",str);
free(str);
return 0;
}
查看7道真题和解析
