forked from KolibriOS/kolibrios
Quicksort dll and example.
git-svn-id: svn://kolibrios.org@3402 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
61
programs/develop/libraries/qs/example/example.c
Normal file
61
programs/develop/libraries/qs/example/example.c
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
#include "kolibri.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "console.c"
|
||||
|
||||
|
||||
void (* __stdcall qsi)(int* d, int n);
|
||||
|
||||
/// ===========================================================
|
||||
|
||||
void kol_main()
|
||||
{
|
||||
|
||||
#define NUM 20000
|
||||
|
||||
kol_struct_import *imp_qs;
|
||||
|
||||
int *a;
|
||||
int i;
|
||||
|
||||
CONSOLE_INIT("Example");
|
||||
|
||||
imp_qs = kol_cofflib_load("/sys/lib/qs.obj");
|
||||
qsi = ( _stdcall void (*)(int*, int))
|
||||
kol_cofflib_procload (imp_qs, "qsi");
|
||||
|
||||
a = malloc(NUM*sizeof(int));
|
||||
|
||||
for (i = 0; i < NUM; i++)
|
||||
*(a+i) = random(10000);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
printf("%7d", *(a+i));
|
||||
|
||||
printf (" ...");
|
||||
|
||||
for (i = NUM-5; i < NUM; i++)
|
||||
printf("%7d", *(a+i));
|
||||
|
||||
qsi(a, NUM);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
printf("%7d", *(a+i));
|
||||
|
||||
printf (" ...");
|
||||
|
||||
for (i = NUM-5; i < NUM; i++)
|
||||
printf("%7d", *(a+i));
|
||||
|
||||
|
||||
free(a);
|
||||
|
||||
_exit(0);
|
||||
kol_exit();
|
||||
}
|
||||
|
||||
/// ===========================================================
|
Reference in New Issue
Block a user