Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <pthread.h>
- #include <ctime>
- #include <stdio.h>
- #define n 20000
- #define m 20000
- void sequial(int **matr);
- void fill_matr(int **matr);
- int main()
- {
- srand(time(0));
- try
- {
- int **matr = new int*[n];
- for(int i = 0; i < n; ++i)
- matr[i] = new int[m];
- fill_matr(matr);
- sequial(matr);
- for(int i = 0; i < n; ++i)
- delete[] matr[i];
- delete matr;
- }
- catch(...)
- {
- printf("Error!\n");
- return 0;
- }
- system("pause");
- return 0;
- }
- void sequial(int **matr)
- {
- int my_max = 0;
- clock_t my_time = clock();
- for(int i = 0; i < n; ++i)
- {
- for(int j = i; j < m; ++j)
- {
- if(my_max < matr[i][j]) my_max = matr[i][j];
- }
- }
- my_time = clock() - my_time;
- printf("sequial:\tmax_el = %i\ttime: %.6lf\n", my_max, (double)my_time/CLOCKS_PER_SEC);
- }
- void fill_matr(int **matr)
- {
- for(int i = 0; i < n; ++i)
- {
- for(int j = i; j < m; ++j)
- {
- matr[i][j] = rand() % 3000;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement