Advertisement
pexea12

ex3p3.c

Feb 3rd, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. #define N 15000
  5. int a[N][N];
  6.  
  7. void main() {
  8.   int i,j;
  9.   clock_t t1,t2;
  10.  
  11.  
  12.   /* Begin measurement */
  13.   t1 = clock();
  14.   for (i=0;i<N;i++)
  15.     for (j=0;j<N;j++)
  16.       a[i][j]=(i+j)/2;
  17.   t2 = clock();
  18.   /* End measurement */
  19.  
  20.  
  21.  
  22.   for (i=0;i<N;i+=10000) for (j=0;j<N;j+=10000) printf("%d ",a[i][j]);
  23.   printf("\n");
  24.  
  25.   double tcpu = (double) (t2 -t1) / CLOCKS_PER_SEC;
  26.   printf("Time: %f\n", tcpu);
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement