Skip to content

Instantly share code, notes, and snippets.

@csr
Created April 10, 2016 18:28
Show Gist options
  • Save csr/eff7f4a65ae8f0951a9d99ab7578f874 to your computer and use it in GitHub Desktop.
Save csr/eff7f4a65ae8f0951a9d99ab7578f874 to your computer and use it in GitHub Desktop.
Ordine decrescente
void bubbleSort(int vettore[], int lunghezzaArray) {
int tmp;
for (int i = 0; i < lunghezzaArray-1; i++) {
if (vettore[i] > vettore[i+1]) {
tmp = vettore[i];
vettore[i] = vettore[i+1];
vettore[i+1] = tmp;
}
}
}
void stampaOrdineDecrescentePagaOrariaAllenatori(struct Allenatore insiemeAllenatori[]) {
int pagaOraria[numeroMassimoAllenatori];
int i, z = 0;
for (i = 0; i < numeroMassimoAllenatori; i++) {
if (insiemeAllenatori[i].codiceAllenatore != -1) {
pagaOraria[z] = insiemeAllenatori[i].pagaOraria;
z++;
}
}
bubbleSort(pagaOraria, numeroMassimoAllenatori);
for (i = numeroMassimoAllenatori; i < 0; i--) {
printf("La paga oraria e' %d\n.", pagaOraria[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment