c++字符串的反转操作之一用STL直接倒序输出

#include<bits/stdc++.h>   //文件头
using namespace std;
string a;                 //定义字符串
int main() 
{
    cin>>a;               //输入
    reverse(a.begin(),a.end());  //反转
    cout<<a;              //输出
    return 0;             //养成好习惯
}

格式是: reverse(数组名.begin(),数组名.end())

无标签
评论区
头像