Created
May 21, 2015 14:03
-
-
Save auduchinok/fafd34431a709864fcf2 to your computer and use it in GitHub Desktop.
Matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <iostream> | |
#include <omp.h> | |
using namespace std; | |
int main() | |
{ | |
const int n = 10; | |
int *mArray = new int[n * n]; | |
int **m = new int*[n]; | |
for (int i = 0; i < n; i++) | |
{ | |
m[i] = &mArray[n * i]; | |
} | |
for (int i = 0; i < n; i++) | |
{ | |
for (int j = 0; j < n; j++) | |
{ | |
m[i][j] = i * n + j; | |
cout << m[i][j] << " "; | |
} | |
cout << endl; | |
} | |
int max_value = 0; | |
int threads_number = 2; | |
#pragma omp parallel for reduction(max: max_value) | |
for (int i = 0; i < n * n; i++) | |
{ | |
if (mArray[i] > max_value) | |
{ | |
max_value = mArray[i]; | |
} | |
} | |
cout << "max: " << max_value << endl; | |
cin.get(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment