-3
如何检查一个数组或链表是否被排序或没有使用C++?给定一组数字?有没有可用于检查的功能?如何检查链表是否使用C++排序?
如何检查一个数组或链表是否被排序或没有使用C++?给定一组数字?有没有可用于检查的功能?如何检查链表是否使用C++排序?
只需使用std::is_sorted
类似:
if (std::is_sorted(std::begin(linked_list), std::end(linked_list)) {
//...
}
检查这个堆栈溢出链接希望你得到它你的答案。
[性病::已排序(http://en.cppreference.com/w/cpp/algorithm/is_sorted) – Jarod42
http://stackoverflow.com/questions/35182013/how-can- i-check-if-vector-elements-is-order-order- –
Cody Grey刚刚发布的链接上的最佳答案。试着在这里用一些关键字搜索一下,然后再问:) – George