睡眠排序
二半夜的有点失眠,来个睡眠排序 -_-||
#include <iostream> #include <thread> #include <windows.h> #include <vector> using namespace std; void delay(int a) { Sleep(a); cout << a <<" "; } int main() { int a[10] = { 30, 45, 23, 1, 43, 5, 7, 34, 32, 2 }; for (int i = 0; i < 10; i++) { thread t(delay, a[i]); t.detach(); } getchar(); return 0; }