题目描述:
将一个字符串str的内容颠倒过来,并输出。str的长度不超过100个字符。
输入包括一行。 第一行输入的字符串。
输出转换好的逆序字符串。
I am a student
样例输出:
tneduts a ma I
代码实现:
#include <iostream> #include <string> #include <algorithm> //使用STL库函数 using namespace std; int main() { string str; getline(cin,str);//不能用cin,因为cin不会读取空格 reverse(str.begin(),str.end()); //reverse倒转函数,str为字符串名逗号前后为首末地址 cout << str << endl; system("pause"); return 0; }
0.0分
0 人评分