【笨方法学PAT】对字符串的reverse

版权声明:欢迎转载,请注明来源 https://blog.csdn.net/linghugoolge/article/details/82825584

一、reverse

string s;

reverse(s.begin(),s.end());

头文件:#include<algorithm>

二、代码

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s = "Hello";
	string s1 = s;

	reverse(s.begin(), s.end());
	//Hello
	cout << s;

	//olleH
	cout << s1;
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/linghugoolge/article/details/82825584