Solution: Find and remove strings

Title Description
Given a short string (without spaces), to give a plurality of fixed character string, remove short string contained in these strings.
Input
Input only one set of data.

Enter a short string (without spaces), and then until the end of the input character string until a number of files.
Output
remove short string entered (case insensitive) and remove spaces output.
Sample input
in
#include
int main ()
{

the printf ( "the Hi");
}
sample output
#clude
TMA ()
{

PRTF ( "the Hi");
}
Tip
NOTE: The string In, IN, iN, in deleted.
You can only output a character putchar
getchar not only read the letter, read into the line breaks and spaces;
detailed source of ideas

#include<iostream>
#include<cstring>
using namespace std;
char st[100],t[1000][1000],ch;
int main()
{
 cin>>st;
 int len=strlen(st);
 int i=0;
 ch=getchar();//读入换行符 
 while((ch=getchar())!=EOF)
 {
  if(tolower(ch)==tolower(st[i]))
  {
   i++;
  if(i==len) i=0; // 删除 
 }
 else
 {
  if(i==0)
  {
   if(ch!=' ') putchar(ch);
  }
  else
  {
   for(int k=0;k<i;k++)
    putchar(st[k]);
   i=0;
   if(ch!=' ')
   putchar(ch);
  }
 }
 }
 return 0;
}

Guess you like

Origin blog.csdn.net/weixin_43540515/article/details/91042529