Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     int L;
  8.     int i;
  9.     clock_t t_start, t_end, t_total;
  10.     int sum = 0;
  11.     scanf("%d", &L);
  12.     {
  13.         int* p = (int*)malloc(L * sizeof(int));
  14.         int* a = (int*)malloc(L * sizeof(int));
  15.         for (i = 0; i < L; ++i)
  16.             scanf("%d", &a[i]);
  17.         for (i = 0; i < L; ++i)
  18.             p[i] = i;
  19.         t_start = clock();
  20.         for (i = 0; i < L; ++i)
  21.             sum += a[p[i]];
  22.         t_end = clock();
  23.         t_total = (double)(t_end - t_start) / CLOCKS_PER_SEC;
  24.         printf("%lf", t_total);
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement