Código C:
Ver original
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> void swap(int *a, int *b) { int t=*a; *a=*b; *b=t; } void quicksort(int arr[], int beg, int end) { if (end > beg + 1) { int piv = arr[beg], l = beg + 1, r = end; while (l < r) { if (arr[l] >= piv) l++; else swap(&arr[l], &arr[--r]); } swap(&arr[--l], &arr[beg]); quicksort(arr, beg, l); quicksort(arr, r, end); } } int main() { float total,inicio, final; FILE *ARCH, *ARCHI; int N; int d[N], a; a=0; for(a=0;a<N;a++) { } int length; length=N; int i; for(i=0;i<length;i++) { quicksort(d, 0, length); } total=(final-inicio)/(double) CLOCKS_PER_SEC; return 0; }