Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ reverse vector

#include <bits/stdc++.h> // Vector
#include <algorithm>  // Reverse 
using namespace std;

int main()
{
    vector<int> nums{4,1,2,1,2};

    reverse(nums.begin(), nums.end());
    return 0;
}
Comment

how to sort a vector in reverse c++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
   vector<int> v = { 10, 9, 8, 6, 7, 2, 5, 1 };
   sort(v.begin(), v.end(), greater <>());
}
Comment

C++ reverse vector

// C++ program to reverse Vector
// using reverse() in STL
 
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    // Get the vector
    vector<int> a = { 1, 45, 54, 71, 76, 12 };
 
    // Print the vector
    cout << "Vector: ";
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << " ";
    cout << endl;
 
    // Reverse the vector
    reverse(a.begin(), a.end());
 
    // Print the reversed vector
    cout << "Reversed Vector: ";
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << " ";
    cout << endl;
 
    return 0;
}
Comment

how to reverse a vector

//vector<int> A;
reverse(A.begin(),A.end());
Comment

c++ reverse part of vector

//Reverse vector partially (from index x to index y)
reverse(v.begin()+x, v.begin()+y+1);
Comment

c++ reverse vector

#include <vector>
#include <algorithm>

int main() {
  std::vector<int> a;
  std::reverse(a.begin(), a.end());
  return 0;
}
Comment

reverse in vector c++

reverse(start_index, last_index);
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to sort a vector in reverse c++ 
Cpp :: how to iterate through a map in c++ 
Cpp :: avrational compare 
Cpp :: sort a vector of strings according to their length c++ 
Cpp :: UNIX c++ delay 
Cpp :: c++ flush stdin 
Cpp :: unordered_map of pair and int 
Cpp :: eosio multi index secondary index 
Cpp :: hello world in cpp 
Cpp :: c++ fill array with 0 
Cpp :: sony pictures animation films produced 
Cpp :: check if double is integer c++ 
Cpp :: fill two dimension array c++ 
Cpp :: search update delete files in c++ 
Cpp :: get ascii value of qchar 
Cpp :: cannot open include file unreal 
Cpp :: eosio get time 
Cpp :: assign a struct to another c++ 
Cpp :: string to char array c++ 
Cpp :: C compile SDL program using mingw 
Cpp :: how to writt array in c++ 
Cpp :: print vector 
Cpp :: c++ print current time 
Cpp :: comment in c++ 
Cpp :: clang cpp compile command 
Cpp :: cpp merge two sets 
Cpp :: capitalize first letter c++ 
Cpp :: c++ infinite for loop 
Cpp :: parallelize for loop c++ 
Cpp :: use ::begin(WiFiClient, url) 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =