Skip to content

Instantly share code, notes, and snippets.

@Silva97
Created March 21, 2020 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Silva97/f3571727757ef604b63403830728d0a2 to your computer and use it in GitHub Desktop.
Save Silva97/f3571727757ef604b63403830728d0a2 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int cmpfloat(const void *n1, const void *n2)
{
return *( (const float *) n1 ) > *( (const float *) n2 );
}
#define SIZE 3
int main(int argc, char **argv)
{
float numbers[SIZE];
printf("Digita os bagulho: ");
scanf("%f%f%f", &numbers[0], &numbers[1], &numbers[2]);
qsort(numbers, SIZE, sizeof *numbers, cmpfloat);
for (int i = 0; i < SIZE; i++)
printf("%.2f, ", numbers[i]);
putchar('\n');
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment