0
点赞
收藏
分享

微信扫一扫

华为机试题——HJ12 字符串反转

Raow1 2022-04-19 阅读 123
c++

描述

接受一个只包含小写字母的字符串,然后输出该字符串反转后的字符串。(字符串长度不超过1000)

输入描述:

输入一行,为一个只包含小写字母的字符串。

输出描述:

输出该字符串反转后的字符串。

示例1

输入:

abcd

复制输出:

dcba
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <algorithm>

int main()
{
    std::string str;
    getline(std::cin, str);
    std::reverse(str.begin(), str.end());
    std::cout << str << std::endl;
    
    return 0;
}
举报

相关推荐

0 条评论