#include#include#includeintmain(){
std::vector<int> v = {1, 2, 3, 4, 5};
if (std::is_sorted(v.begin(), v.end())) {
std::cout << "The vector is sorted."<< std class="hljs-keyword">else {
std::cout << "The vector is not sorted."<< std class="hljs-keyword">return 0;
}
在这个示例中,我们创建了一个包含整数的向量,并使用 std::is_sorted 来检查该向量是否已经排序。如果向量已经排序,我们将输出 “The vector is sorted.”,否则将输出 “The vector is not sorted.”。