Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PRÁCTICA DE QUICKSORT
#include <stdio.h> #include <stdlib.h> typedef struct { char name[101]; unsigned short age; float score; }player; // --------------------Prototypes-------------------- void input( player *, unsigned short ); int compareScore( const void * , const void * ); // ---------------------------Main Program------------------------ int main(void) { player listOfPlayers[10000]; unsigned short total, i; scanf("%hu\n", &total); input(listOfPlayers, total); qsort(listOfPlayers, total, sizeof(player), compareScore); printf("\nORDER BY SCORE\n"); printf("==============\n"); for ( i = 0 ; i < total ; i ++ ) printf("%s %hu %.1f\n", listOfPlayers[i].name, listOfPlayers[i].age, listOfPlayers[i].score); return 0; } //------------------------------Functions---------------------------------- void input( player *list, unsigned short total) { unsigned short i; for ( i = 0 ; i < total ; i ++ ) { scanf("%100[^,]s", list[i].name); getchar(); scanf("%hu", &list[i].age); getchar(); scanf("%f", &list[i].score); getchar(); } for ( i = 0 ; i < total ; i ++ ) printf("%s %hu %.1f\n", list[i].name, list[i].age, list[i].score); } int compareScore( const void *pivot , const void *element ) { player *ptrPivot = ( player * ) pivot; player *ptrElement = ( player * ) element; return (ptrElement -> score) - (ptrPivot -> score); }
run
|
edit
|
history
|
help
0
quadsort vs qsort
Avance Pregunta 2 guía 4
Incometax problem v0.1
cstructCensus
time.c
20171117_FUNCIONES
fgets and basic string manipulation
Sheldon 9 area none aliens as aliens and farms Lockheed Kelly and lame lead district 9
14th Dec Project1 v0.4
segundo avance de la lista enlazada