题解 | #字符逆序#

字符逆序

https://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b

#include <iostream>
#include<string>
#include<vector>
using namespace std;

/* 将一个字符串str的内容颠倒过来,并输出。
数据范围:
1≤len(str)≤10000 
输入描述:
输入一个字符串,可以有空格
输出描述:
输出逆序的字符串*/
int main()
{
	// 输入可以有空格 可以采用getline()
	string str;
	getline(cin, str);
	for (auto it = str.rbegin(); it != str.rend(); it++)//采用逆序迭代器
	{
		cout << *it ;
	}
	system("pause");
	return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务