以下是C++的代码实现,用于将用户输入的字符串倒置:

#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string input;
    std::cin >> input;

    std::reverse(input.begin(), input.end());

    std::cout << input << std::endl;

    return 0;
}

这个程序首先读取输入的字符串,然后使用std::reverse函数将字符串倒置,最后输出倒置后的字符串。

C++ 字符串倒置:简单实现与代码示例

原文地址: https://www.cveoy.top/t/topic/jgQx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录