Codeup 1967 問題 C: 數組逆置

題目鏈接http://codeup.cn/problem.php?cid=100000604&pid=2

題目描述
輸入一個字符串,長度小於等於200,然後將數組逆置輸出。

輸入
測試數據有多組,每組輸入一個字符串。

輸出
對於每組輸入,請輸出逆置後的結果。

樣例輸入
tianqin

樣例輸出
niqnait

代碼

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

int main() {
	string str;
	while(getline(cin, str)){
		reverse(str.begin(), str.end());
		cout<<str<<endl;
	}
	return 0;
}
發佈了186 篇原創文章 · 獲贊 9 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章