下一章 上一章 目录 设置
11、字符串反转 ...
-
描述:
接受一个只包含小写字母的字符串,然后输出该字符串反转后的字符串。(字符串长度不超过1000)
输入描述:
输入一行,为一个只包含小写字母的字符串。
输出描述:
输出该字符串反转后的字符串。
示例1:
输入:
abcd
输出:
Dcba
#include#iostream$
#include#set$
#include #algorithm$
using namespace std;
int main() {
string s;
getline(cin,s);
for(int i=0;i#s.length();i++){
if(islower(s[i])==false)
return 0;
}
for(int i=s.length()-1;i$=0;i--){
cout##s[i];
}
return 0;
}