C++函数string

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
void f(int);
int n;
int main()
{
	system("color 1");
	string a,b;
	int s=1;
	cin>>a;
	int la=a.size();
	for(int i=la;i>=1;i--){
		b[s]=a[i];
		s++;
	}
	if(b.find("re")==1||b.find("yl")==1){
		b.erase(1,2);
	}
	else if(b.find("gni")==1){
		b.erase(1,3);
	}
	reverse(b.begin(),b.end());
	cout<<b;
	return 0;
}
void f(int n){
	
	return;
}
cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
void f(int);
int n;
int main()
{
	system("color 1");
	string a,b;
	getline(cin,a);
	cin>>b;
	int x=a.find(b);
	a.erase(x,b.size());
	cout<<a;
	return 0;
}
void f(int n){
	
	return;
}
cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
void f(int);
int n;
int main()
{
	system("color 1");
	string a,b;
	getline(cin,a);
	cin>>b;
	int x;
	n=a.size();
	for(int i=1;i<=n;i++){
		x=a.find(b);
		a.erase(x,b.size());
	}
	cout<<a;
	return 0;
}
void f(int n){
	
	return;
}
cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
void f(int);
int n;
int main()
{
	system("color 1");
	string a,b;
	getline(cin,a);
	cin>>b;
	int x;
	n=a.size();
	for(int i=1;i<=n;i++){
		x=a.find(b);
		a.replace(x,b.size(),a);
	}
	cout<<a;
	return 0;
}
void f(int n){
	
	return;
}
相关推荐
沐怡旸2 小时前
【底层机制】std::string 解决的痛点?是什么?怎么实现的?怎么正确用?
c++·面试
River4165 小时前
Javer 学 c++(十三):引用篇
c++·后端
感哥7 小时前
C++ std::set
c++
侃侃_天下8 小时前
最终的信号类
开发语言·c++·算法
博笙困了8 小时前
AcWing学习——差分
c++·算法
echoarts8 小时前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Aomnitrix8 小时前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
青草地溪水旁9 小时前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(2)
c++·设计模式·抽象工厂模式
青草地溪水旁9 小时前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(1)
c++·设计模式·抽象工厂模式
感哥9 小时前
C++ std::vector
c++