Advertisement
MrHalabaluza

Untitled

Oct 5th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "windows.h"
  3. #include "stdlib.h"
  4. #include "time.h"
  5.  
  6. #define BUFFER_SIZE 1000000
  7. #define FIRST_ELEM 0
  8.  
  9. int main(){
  10.     unsigned int start_time;
  11.     unsigned int end_time;
  12.     int arr_length = 0;
  13.     int i = 0;
  14.     int * arr;
  15.     arr = malloc(BUFFER_SIZE*sizeof(int));
  16.     if (!arr){
  17.         return 1;
  18.     }
  19.     srand(time(NULL));
  20.     scanf("%d", &arr_length);
  21.     for (i; i < arr_length; i++){
  22.         arr[i] = rand();
  23.     }
  24.     start_time = GetTickCount();
  25.     quickSort(arr, FIRST_ELEM, arr_length - 1);
  26.     end_time = GetTickCount();
  27.     printf("\n%d\n", end_time - start_time);
  28.     free(arr);
  29.     arr = NULL;
  30.     system("pause");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement