题目:
重新编写squeeze(s1, s2),将字符串s1中任何与字符串s2中字符匹配的字符都删除。
自我解答:
#include <stdio.h>
#define MAXSIZE 1000
char news1[MAXSIZE];
/* remove the same character in s2 from s1 */
void squeeze(const char s1[], const char s2[])
{
int i = 0; /* i is the counter for s1 */
int j = 0; /* j is the counter for s2 */
int k = 0; /* k is the counter for news1 */
bool findc = false;
while(s1[i] != '\0')
{
j = 0;
while(s2[j] != '\0')
{
if(s1[i] == s2[j])
findc = true;
j++;
}
if(!findc) /* not find the same character */
news1[k++] = s1[i];
else
findc = false;
i++;
}