題目描述
輸入一個字符串,長度小於等於200,然後將數組逆置輸出。
輸入
測試數據有多組,每組輸入一個字符串。
輸出
對於每組輸入,請輸出逆置後的結果。
樣例輸入
tianqin
樣例輸出
niqnait
提示
注意輸入的字符串可能會有空格。
思路:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
while(getline(cin, str))
{
for(int i=0, j=str.size()-1; i<j; i++, j--)
{
swap(str[i], str[j]);
}
cout << str<< endl;
}
return 0;
}