voidquick_sort(std::vector<int>& arr) { if (arr.empty()) { return; } quick_sort(arr, 0, arr.size() - 1); } voidquick_sort(std::vector<int>& arr, int left, int right) { if (left >= right) { return; } // 基准数 取中间元素作为基准数,left + (right - left) / 2是为了防止left+right溢出 int pivotValue = arr[left + (right - left) / 2];
int begin = left - 1, end = right + 1; while (begin < end) { do { begin++; } while (arr[begin] < pivotValue); do { end--; } while (arr[end] > pivotValue);
if (begin < end) { std::swap(arr[begin], arr[end]); } } quick_sort(arr, left, end); // 下面这个的left参数不能使用begin+1,否则会导致一个元素会排序两次 quick_sort(arr, end + 1, right); }
[build] D:/a-mycode/C++/DDZ-NET/client-ddz/thread/include/Communication.h:87:5: error: 'DataManager' has not been declared [build] DataManager::getInstance()->getCommunication()->setCards(cards, last3Cards); [build] ^~~~~~~~~~~
/mnt/d/a-mycode/C++/DDZ-NET/server-ddz/tcp/include/TcpConnection.h:31:5: error: ‘Communication’ does not name a type 31 | Communication* m_reply = nullptr; | ^~~~~~~~~~~~~
原因:你在子目录serialize中添加的上述的动态库路径,但还是报错,可能是其他同级子目录或者上层目录使用了serialize目录的相关代码,因此其他目录也需要链接该动态库,但是由于CMake添加的link_directories只在该目录及其子目录下生效,在其他同级目录和上层目录是不生效的,所以其他目录也会报出错误:cannot found -lxxx