Angel David Yaguana Hernandez
/
CPP_qsort
qsort, descripcion y ejemplo
Diff: main.cpp
- Revision:
- 0:b011c638604b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 03 21:02:30 2012 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +/* qsort example */ +#include <stdio.h> +#include <stdlib.h> + +int values[] = { 40, 10, 100, 90, 20, 25 }; + +int compare (const void * a, const void * b) +{ + return ( *(int*)a - *(int*)b ); +} + +int main () +{ + int n; + qsort (values, 6, sizeof(int), compare); + for (n=0; n<6; n++) + printf (": %d ",values[n]); + return 0; +} \ No newline at end of file