69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//这个是函数
void squeeze(char s1[],char s2[]){
int i,j,m;
for(i=j=0;s1[i]!='\0';i++){
for(m=0;s2[m]!='\0'&&s1[i]!=s2[m];m++)
;
if(s2[m]=='\0'){
s1[j++]=s1[i];
}
}
s1[j]='\0';
}
//下面这一段是正确的
int main(int argc, char *argv[]) {
char s1[100],s2[100];
gets(s1);
while(gets(s2)){
squeeze(s1,s2);
puts(s1);
}
return 0;
}
/*为什么下面这个是错误的???
int main(int argc, char *argv[]) {
char s1[100],s2[100];
while(gets(s1))
;
while(gets(s2)){
squeeze(s1,s2);
}
return 0;
}*/
fgets(s1, 100, stdin);
s1[strlen(s1) - 1] = '\0';