lundi 2 janvier 2017

Having Trouble in Using is_sorted in C++

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int i, j, t;
    vector <int> v;
    scanf("%d", &t);

    while(t--) {
        scanf("%d", &j);
        v.push_back(j);
    }

    if(is_sorted(v.begin(), v.end()))
        printf("Sorted\n");
    else
        printf("Unsorted\n");

    return 0;
}

Here's my C++ code to check whether a vector is sorted or not. But my IDE (Code Blocks) doesn't compile it and gives the message "is_sorted was not declared in this scope". What's wrong with this code?

Aucun commentaire:

Enregistrer un commentaire