Horje
how to check if vector is ordered c++ Code Example
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\n";
    else
        cout << "a is not sorted\n";
    
    if(is_sorted(b.begin(), b.end()))
        cout << "b is sorted\n";
    else
        cout << "b is not sorted\n";
}




Cpp

Related
priority queue smallest first Code Example priority queue smallest first Code Example
how to format decimal palces in c++ Code Example how to format decimal palces in c++ Code Example
if argv == string Code Example if argv == string Code Example
input n space separated integers in c++ Code Example input n space separated integers in c++ Code Example
how to download c++ portable compiler Code Example how to download c++ portable compiler Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8