Facebook
From Capacious Parakeet, 6 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 360
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <omp.h>
  4. #include <windows.h>
  5.  
  6. const int row = 100;
  7. const int col = 100;
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.         float tab[row][col];
  12.         clock_t start, stop;
  13.  
  14.         for (int i = 0; i < col; i++)
  15.         {
  16.                 for (int j = 0; j < col;j++)
  17.                 {
  18.                         tab[i][j] = (float)rand() / RAND_MAX;
  19.  
  20.                 }
  21.         }
  22.         float sum = 0.0;
  23.  
  24.  
  25.         start = clock();
  26.  
  27.         for (int i = 0; i < col; i++)
  28.         {
  29.                 for (int j = 0; j < col;j++)
  30.                 {
  31.                         sum += tab[i][j];
  32.  
  33.                 }
  34.         }
  35.         stop = clock();
  36.         printf("wynik %fn %fn", start, stop);
  37.  
  38.         printf("wynik %.2fn", sum);
  39.         printf("Czas przetwarzania wynosi %f sekundn", ((double)(stop - start) / 1000.0));
  40.  
  41.  
  42.         return 0;
  43.  
  44. }
  45.  
  46.