posir 发表于 2017-7-10 19:09:51

[华为]字符逆序

  链接:https://www.nowcoder.com/questionTerminal/cc57022cb4194697ac30bcb566aeb47b
来源:牛客网


  将一个字符串str的内容颠倒过来,并输出。str的长度不超过100个字符。 如:输入“I am a student”,输出“tneduts a ma I”。
  
输入参数:
  inputString:输入的字符串
  
返回值:
  输出转换好的逆序字符串

输入描述:
  输入一个字符串,可以有空格
  




输出描述:
  输出逆序的字符串

输入例子:

I am a student

输出例子:

tneduts a ma I




#include <iostream>
#include <string>
using namespace std;
int main()
{   
string str;   
getline(cin,str);   
for(int i = str.size()-1;i>=0;i--)      
cout << str;
}
页: [1]
查看完整版本: [华为]字符逆序