#include <iostream>
#include <omp.h>
#include <cmath>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
double omp_time1, omp_time2;
int n;
cout << "Podaj rozmiar macierzy"<< endl;
cin >> n;
double **A = new double*[n];
double **B = new double*[n];
double **C = new double*[n];
for(int i=0;i<n;++i)
{
A[i]= new double[n];
B[i]= new double[n];
C[i]= new double[n];
}
ofstream dopliku("macierze.txt");
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
A[i][j] = rand() %100 + 1;
B[i][j] = rand() %100 + 1;
}
}
#pragma omp parallel
{
#pragma omp sections
{
#pragma omp section
{
omp_time1 = omp_get_wtime();
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
dopliku << A[i][j];
dopliku << B[i][j];
}
}
dopliku.close();
cout << "Koniec zapisu" << endl;
omp_time1 =omp_get_wtime()-omp_time1;
}
#pragma omp section
{
omp_time2 = omp_get_wtime();
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
for(int k=0;k<n;++k)
{
C[i][j] += A[i][k] * B[k][j];
}
}
}
cout << "Koniec obliczen" << endl;
omp_time2 =omp_get_wtime()-omp_time2;
}
}
}
cout << "Czas sekcji zapisu " << omp_time1 << endl;
cout << "Czas sekcji obliczen " << omp_time2 << endl;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}