标签:out his code this read The clu 一个 sleep
之前在网上看到了一个叫做睡觉排序法,大部分是用java实现的
现在我用c++实现一下
void sleepSortHelper(int i) { this_thread::sleep_for(chrono::microseconds(i*10000)); std::cout << i << " "; } void sleepSort(int *arr,int size) { for (int i = 0; i < size; i++) { std::thread t(sleepSortHelper,arr[i]); t.detach(); } } void main() { sleepSort(arr, 7); getchar(); }
记住要添加头文件
#include<thread>
标签:out his code this read The clu 一个 sleep
原文地址:https://www.cnblogs.com/zezeze/p/10130552.html