1295:字符串逆序输出
Sample Input
3
Frankly, I don't think we'll make much
money out of this scheme.
madam I'm adam
Sample Output
hcum ekam ll'ew kniht t'nod I ,ylknarF
.emehcs siht fo tuo yenom
mada m'I madam
简单题。。 借助stl库 algorithm中 reverse函数。
读取用到gets(char*) 含空白符的整行读取 getchar 读取单字符。
Sample Input
3
Frankly, I don't think we'll make much
money out of this scheme.
madam I'm adam
Sample Output
hcum ekam ll'ew kniht t'nod I ,ylknarF
.emehcs siht fo tuo yenom
mada m'I madam
简单题。。 借助stl库 algorithm中 reverse函数。
读取用到gets(char*) 含空白符的整行读取 getchar 读取单字符。
#include<iostream>
using namespace std;
#include<cstring>
#include<algorithm>
#include<stdio.h>
int main()
{
string s;
char src[70];
int n;
cin>>n;
getchar(); //把换行符读走,下面按行读取
for(int i=0;i<n;i++)
{
gets(src);
s = string(src);
reverse(s.begin(),s.end());
cout<<s.c_str()<<endl;;
}
}