我有一個unordered_set
稱爲方程。我不是來排序或快速排序是,這是跑辦代碼IM線:Qsort or Sort on unordered_set
qsort(&equations, equations.size(), sizeof(string), strcmp);
我得到的錯誤是:
error: cannot convert 'std::unordered_set<std::basic_string<char> >' to 'void*'
for argument '1' to 'void qsort(void*, size_t, size_t, __compar_fn_t)'
qsort(equations, equations.size(), sizeof(string), strcmp);
A)'unordered_set'無法排序。您需要將其內容複製到一個'vector',或者用你自己的排序標準使用'std :: set'。 B)'qsort'是一個C函數。它不會理解如何處理用戶定義的類型,如C++容器。你可能想要'std :: sort'。 – juanchopanza
排序的語法是什麼? @juanchopanza – user3121369
看看。這裏有大約二百億個問題。 – juanchopanza