版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40712616/article/details/79534008
第五弹!
第五弹!第五弹!
#include <stdio.h>
#define max 1000
void InputSpring(char s[]);
//void mySqueeze(char s1[],char s2[]);
void any(char s1[],char s2[]);
void main()
{
char S1[max],S2[max];
InputSpring(S1);
InputSpring(S2);
// mySqueeze(S1,S2);
any(S1,S2);
printf("%s\n",S1);
}
void InputSpring(char s[])
{
int i;
int c;
for(i = 0; (c = getchar())!=EOF && c!='\n' && i<max; i++)
{
s[i] = c;
}
if(c == '\n')
{
s[i++] = '\0';
}
}
/****************************
* Remark:
* s1 and s2 are String format.
* so the position of the '\0'
* has been changing when runing
* the FOR.
****************************/
void mySqueeze(char s1[],char s2[])
{
int i,j,k;
for(i = 0; s2[i]!='\0'&& i<=max; i++)
{
for(j = k = 0; s1[j]!='\0'&& j<=max; j++)
{
if(s1[j] != s2[i])
{
s1[k++] = s1[j];
}
}
s1[k] = '\0';
}
}
void any(char s1[],char s2[])
{
int i,j;
for(i = 0; s2[i]!='\0'&& i<=max; i++)
{
for(j = 0; s1[j]!='\0'&& j<=max; j++)
{
if(s1[j] == s2[i])
{
s1[j] = '\0';
}
}
}
}