kolibrios/programs/develop/libraries/qs/example/example.c
Albom d21d1d7b9c Quicksort dll and example.
git-svn-id: svn://kolibrios.org@3402 a494cfbc-eb01-0410-851d-a64ba20cac60
2013-03-22 17:53:23 +00:00

62 lines
947 B
C

#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();
}
/// ===========================================================