Advertisement
Tvor0zhok

ParProg4.3

Feb 26th, 2023
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <omp.h>
  5. using namespace std;
  6.  
  7. int n = 0;
  8.  
  9. int main()
  10. {
  11.     setlocale(LC_ALL, "Russian");
  12.  
  13.     cout << "Последовательная область\n";
  14.  
  15. #pragma omp parallel
  16.     {
  17. #pragma omp critical
  18.         {
  19.             n = omp_get_thread_num();
  20.             string s = "Поток №" + to_string(n) + "\n";
  21.             cout << s;
  22.         }
  23.     }
  24.  
  25.     cout << "Снова последовательная область\n";
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement