Sorting algorithms/Sleep sort: Difference between revisions
Content added Content deleted
m (→{{header|Scala}}: Did some formatting) |
|||
Line 114:
=={{header|C++}}==
<lang cpp>
#include <iostream>
#include <thread>
#include <vector>
▲#include <unistd.h>
int main(int argc, char* argv[]) {
threads.emplace_back([i, &argv]() {
std::this_thread::sleep_for(std::chrono::seconds(arg));
std::cout <<
});▼
for (auto& thread : threads) {
}
▲ vector<thread*> threads;
▲ for( int x = 0; x < 15; x++ )
▲ }
▲ ( *t )->join();
▲ }
}
</lang>
{{out}}
<pre>
./a.out 8 15 14 9 17 20 16 24 6 24 21 23 19 23 19 ▼
6
▲8 15 14 9 17 20 16 24 6 24 21 23 19 23 19
8
9
14
15
16
17
19
19
20
21
23
23
24
24
</pre>
|