More actions
imported>beonit No edit summary |
imported>beonit No edit summary |
||
| Line 1: | Line 1: | ||
* http://isis.poly.edu/kulesh/stuff/src/klist/ | * http://isis.poly.edu/kulesh/stuff/src/klist/ | ||
#include <unistd.h> | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <time.h> | |||
#define MAX 1000000 | |||
int fn_qsort_intcmp( const void *a, const void *b ) | |||
{ | |||
return( *(int *)a - *(int *)b); | |||
} | |||
int main() | |||
{ | |||
int *a; | |||
int i; | |||
int *c; | |||
a = (int *)malloc(sizeof(int)*MAX); | |||
clock_t stime, etime; | |||
for (i = 0; i < MAX; i++) | |||
{ | |||
a[i] = random()%MAX; | |||
} | |||
stime = clock(); | |||
qsort( a, MAX, sizeof(int), fn_qsort_intcmp ); | |||
etime = clock(); | |||
printf("Time : %.3fs\n",(double)(etime - stime)/CLOCKS_PER_SEC); | |||
return 0; | |||
} | |||
Revision as of 12:53, 22 June 2010
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 1000000
int fn_qsort_intcmp( const void *a, const void *b )
{
return( *(int *)a - *(int *)b);
}
int main()
{
int *a;
int i;
int *c;
a = (int *)malloc(sizeof(int)*MAX);
clock_t stime, etime;
for (i = 0; i < MAX; i++)
{
a[i] = random()%MAX;
}
stime = clock();
qsort( a, MAX, sizeof(int), fn_qsort_intcmp );
etime = clock();
printf("Time : %.3fs\n",(double)(etime - stime)/CLOCKS_PER_SEC);
return 0;
}