吕金洋


私信TA

用户名:1759624752

访问量:888

签 名:

等  级
排  名 4016
经  验 1718
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校 南京邮电大学
专  业

  自我简介:

TA的其他文章

#include <iostream>
#include <string>
using namespace std;
string upper_string(string s) {
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] >= 'A' && s[i] <= 'Z')
		{
			s[i] += 32;
		}
	}
	return s;
}
bool ifFind(string s1,string s3,int & position) {
	position = s3.find(s1);
	//找到了
	if (position != s3.npos)
	{
		return true;
	}
	//未找到
	else if (position == s3.npos)
	{ 
		return false;
	}
}
int main(){
string s1, s2, s3, s4;
	cin >> s1;
	getchar();
	int len = s1.length();
	while (getline(cin,s2))
	{
		s1 = upper_string(s1);
		s3 = upper_string(s2);
		int position = -1;
		bool flag = ifFind(s1, s3, position);
		if (!flag)
		{
			cout << s2 << "\n";
		}
		while (flag)
		{
			s4 = "";
			for (int i = 0; i < s2.length(); i++)
			{
				if (i == position)
				{
					i += len - 1;
				}
				else if (s2[i] == ' ')
				{

				}
				else {
					s4 += s2[i];
				}
			}
			s2 = s4;
			s3 = upper_string(s2);
			position = -1;
			flag = ifFind(s1,s3, position);
			if (!flag)
			{
				cout << s4 << endl;
			}
		}
	}
	return 0;
}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区