📜  如何检查向量是否已订购c ++代码示例

📅  最后修改于: 2022-03-11 14:44:57.259000             🧑  作者: Mango

代码示例1
#include  // vector 
#include  // is_sorted
#include  // cout 
using namespace std;
int main()
{
    vector a = {6,5,3,5,7,8,5,2,1};
    vector 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";
}