MAY


私信TA

用户名:may19950501

访问量:8323

签 名:

等  级
排  名 4076
经  验 1707
参赛次数 0
文章发表 14
年  龄 0
在职情况 学生
学  校 哈尔滨学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<iostream>

#include<bits/stdc++.h>

#include<cstring>

#include<cmath>

#include<cstdio>

#include<set>

using namespace std;



int main()

{

    string str0,str;

    cin>>str0;

    str=str0;

    transform(str0.begin(), str0.end(), str0.begin(), ::toupper);//将str0变成大写

    int len=str0.size();

    

    string stra,strb;

    getchar();

    while(getline(cin,stra))

    {

       //删空格

         int x=stra.find (' ');

        while(x!=-1)

        {

            stra.erase(x,1);

            x=stra.find (' ',x);

        }

    strb=stra;

        transform(stra.begin(), stra.end(), stra.begin(), ::toupper);//将stra变成大写

        x=stra.find (str0);

        while(x!=-1)

        {

            stra.erase(x,len);

            //删除子串,两个字符串同步删除

            strb.erase(x,len);

            x=stra.find (str0,x);

        }

        cout<<strb<<endl;

    }


    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

为什么子串要同时删除呀
2019-07-19 20:12:14
  • «
  • 1
  • »