Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication3.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include "omp.h"
- #include <iostream>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "RUS");
- cout << "Bведите число потоков " << endl;
- int threads;
- cin >> threads;
- int n;
- cout << "Введите N" << endl;
- cin >> n;
- omp_set_num_threads(threads);
- int sum = 0;
- int i = 1;
- #pragma omp parallel reduction(+:sum)
- {
- while (i < n)
- {
- sum += i;
- i++;
- }
- printf("sum=%d\n", sum);
- }
- cout <<"Sum = "<< sum << endl;;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement