Answers for "reverse in c++ stl"

C++
1

string reverse stl

int main() { 
    string str = "foobarbaz";
    reverse(str.begin(), str.end()); 
    cout << str; // prints "zabraboof"
    return 0; 
}
Posted by: Guest on March-13-2021
2

reverse() in c++

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
    vector<int>a = {11,22,33,44,99,55};
    reverse(a.begin(), a.end());
    auto it = a.begin();
    for(it= a.begin(); it!=a.end(); it++){
        cout << *it << ' ';    
    }
}
Posted by: Guest on March-05-2021
0

reverse in vector c++

reverse(start_index, last_index);
Posted by: Guest on May-03-2020
-1

reverse string c++

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string str;
  getline(cin,str);
  reverse(str.begin(),str.end());
  cout<<str;
}
Posted by: Guest on July-06-2021

Browse Popular Code Answers by Language