Professional Documents
Culture Documents
OpenMP CPP
OpenMP CPP
h>
#include <stdio.h>
// iostream tends to output each part between <<'s separately to the console,
// which can lead to random output if multiple threads are doing the same
// thing.
// printf will generally output the whole result string in one go, so results
// of separate printf calls, even from different threads, will remain intact
// Another fix, other than using printf, would be to give each thread its own
// place to store output temporarily (a stringstream), and then output the whole
// result in one go.
int main() {