Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to check if vector is ordered c++

#include <vector> // vector 
#include <algorithm> // is_sorted
#include <iostream> // cout 
using namespace std;
int main()
{
    vector<int> a = {6,5,3,5,7,8,5,2,1};
    vector<int> b = {1,2,3,4,5,6,7,8,9};
    
    if(is_sorted(a.begin(), a.end()))
        cout << "a is sorted
";
    else
        cout << "a is not sorted
";
    
    if(is_sorted(b.begin(), b.end()))
        cout << "b is sorted
";
    else
        cout << "b is not sorted
";
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ get active thread count 
Cpp :: for statement c++ 
Cpp :: z transfrom mathlab 
Cpp :: c++ little endian or big endian 
Cpp :: how to write int variable c++ 
Cpp :: Initialize Vector Iterator Through Vector Using Iterators 
Cpp :: function c++ example 
Cpp :: find vector size in c++ 
Cpp :: c++ hash map key count 
Cpp :: intersection between vector c++ 
Cpp :: auto in c++ 
Cpp :: how to declare an enum variable c++ 
Cpp :: C++ rename function 
Cpp :: c++ convert to assembly language 
Cpp :: c++ multiline string 
Cpp :: C++ Vector Operation Access Elements 
Cpp :: shift element to end of vector c++ 
Cpp :: c++ define function pointer 
Cpp :: valid parentheses in cpp 
Cpp :: cpp substring 
Cpp :: use declaration to define a variable 
Cpp :: An Array declaration by initializing elements in C++ 
Cpp :: cpprestsdk send file 
Cpp :: read a file line by line c++ struct site:stackoverflow.com 
Cpp :: taking integer input from file in c++ 
Cpp :: use textchanged qt cpp 
Cpp :: #include <iostream #include <stdio.h using namespace std; int main() { int a[5]; a[0]=12; a[1]=13; a[2]=14; a[3]=15; 
Cpp :: vector and algorithm 
Cpp :: c++ Testing implementation details for automated assessment of sorting algorithms 
Cpp :: C++ Join thread 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =