提交记录 #323
提交时间:2024-11-26 21:20:06
语言:c
状态:Unaccepted
编译情况:编译成功
code.c: In function ‘exout’:
code.c:18:16: warning: unused variable ‘s’ [-Wunused-variable]
18 | int i = 0, s = 0;
| ^
固定测试点#1:
固定测试点#2:
固定测试点#3:
额外测试点#1:
52【字符】字符替换*——用指针更方便
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int strindex( char *p, char *q ){
int i = 0;
while( *( q + i ) != '\n' && *( q + i ) != '\n'){
if( *( p + i ) != *( q + i ) ){
return 0;
}
i++;
}
return 1;
}
void exout( char *p, char *index, char *m ){
int i = 0, s = 0;
while( strindex( ( p + i ), index ) == 0 ){
putchar( *( p + i ) );
i++;
}
int n = 0;
while( *( index + n ) != '\n'){
i++;
n++;
}
int j = 0;
while( *( m + j ) != '\n' ){
putchar( *( m + j ) );
j++;
}
while( *( p + i ) != '\n' ){
putchar( *( p + i ) );
i++;
}
printf("\n");
return;
}
int main(){
char *p = malloc(sizeof(char) * 200 );
char *index = malloc(sizeof(char) * 20 );
char *m = malloc(sizeof(char) * 20 );
fgets( p, 110, stdin );
fgets( index, 20, stdin );
fgets( m, 20, stdin );
exout( p, index, m );
return 0;
}