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 have a queue as a parameter in c++ 
Cpp :: lambda function in c++ 
Cpp :: c++ array pointer 
Cpp :: c++ constructor call superclass 
Cpp :: exception handling class c++ 
Cpp :: c++ inheritance constructor 
Cpp :: c++ variable types 
Cpp :: c++ find index of element in array 
Cpp :: int max in c++ 
Cpp :: trie code cpp 
Cpp :: how to make a vector in c++ 
Cpp :: one dimensiol array to two dimen c++ 
Cpp :: resharper fold if statement 
Cpp :: hierarchical inheritance in c++ employee 
Cpp :: adding variables c++ 
Cpp :: intlen in c++ 
Cpp :: remove something from stringstream 
Cpp :: how to create an integer in c++ 
Cpp :: balanced brackets in c++ 
Cpp :: hide window c++ 
Cpp :: c++ map 
Cpp :: C++, binary search recursive 
Cpp :: std::string substr 
Cpp :: c++ check first character of string 
Cpp :: long long vs long long int 
Cpp :: C++ Syntax for Passing Arrays as Function Parameters 
Cpp :: check if cin got the wrong type 
Cpp :: Maximum Pairwise Modular Sum codechef solution in c++ 
Cpp :: Code debut C++ 
Cpp :: person parametr cpp 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =