Huawei Written Questions: String Reversal

 

Title description

Write a program that accepts a string, and then outputs the inverted string. (The string length does not exceed 1000)

Enter description:

Enter N characters

Output description:

Output the inverted string

Example 1

Input

abcd

Output

dcba
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s;
    getline(cin ,s);
    reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

 

Published 34 original articles · Like 10 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/weixin_41111088/article/details/104789429