1. 程式人生 > 其它 >字串反轉reverse函式與assign函式

字串反轉reverse函式與assign函式

技術標籤:string字串

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string str="11111sad";
    reverse(str.begin(),str.end());
    cout<<str;
}

#include<iostream>
#include<string>
using namespace std;
int main
() { string str="11111sad",str1; str1.assign(str.rbegin(),str.rend()); cout<<str1; }