提交记录 #331
提交时间:2024-11-26 22:46:07
语言:c
状态:Unaccepted
编译情况:编译成功
code.c: In function ‘main’:
code.c:11:5: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
11 | gets(p);
| ^~~~
| fgets
code.c:10:12: warning: unused variable ‘j’ [-Wunused-variable]
10 | int i, j=0;
| ^
/usr/bin/ld: /tmp/ccoMVcXP.o: in function `main':
code.c:(.text.startup+0x3a): warning: the `gets' function is dangerous and should not be used.
固定测试点#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;
gets(p);
gets(index);
gets(excg);
for(i=0; i<=strlen(p);){
if( (p+i)==strstr(p, index)){
for(int q=0; q<=strlen(excg)-1; q++){
putchar(*(excg+q));
}
i+=strlen(index);
}
else{
putchar(*(p+i));
i++;
}
}
printf("\n");
return 0;
}