提交记录 #332
提交时间:2024-11-26 23:06:32
语言:c
状态:Unaccepted
编译情况:编译成功
code.c: In function ‘main’:
code.c:10:12: warning: unused variable ‘j’ [-Wunused-variable]
10 | int i, j=0;
| ^
固定测试点#1:
固定测试点#2:
固定测试点#3:
附加测试点暂不可用
52【字符】字符替换*——用指针更方便
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(){
char *p = malloc(sizeof(char) * 200 );
char *index = malloc(sizeof(char) * 20 );
char *excg = malloc(sizeof(char) * 20 );
int i, j=0;
fgets(p, 200, stdin);
fgets(index, 20, stdin);
fgets(excg, 20, stdin);
for(i=0; i<=strlen(p);){
if( (p+i)==strstr(p, index)){
for(int q=0; *(excg+q)!='\n'; q++){
putchar(*(excg+q));
}
i+=(strlen(index)-1);
}
else{
putchar(*(p+i));
i++;
}
}
return 0;
}