Skip to content

Instantly share code, notes, and snippets.

@robertodormepoco
Last active February 1, 2021 14:48
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 robertodormepoco/d1907c77163030fe0860b9fa5114e8dc to your computer and use it in GitHub Desktop.
Save robertodormepoco/d1907c77163030fe0860b9fa5114e8dc to your computer and use it in GitHub Desktop.
#include<stdio.h>
#define MAX_DIM 20
int main () {
int a[MAX_DIM];
int i, y, t;
printf ("Inserisci sequenza numeri interi: \n");
do {
scanf("%d", &a[i]);
printf ("Inserito %d\n", a[i]);
i++;
} while ((i < MAX_DIM) && (a[i-1] != 0));
for (i = 0; (i < MAX_DIM) && (a[i] != 0); i++) {
for (y = i; (y < MAX_DIM) && (a[y] != 0); y++) {
if(a[i] > a[y]) {
t = a[i];
a[i] = a[y];
a[y] = t;
}
}
}
printf ("Lista ordinata\n");
for (i = 0; (i < MAX_DIM) && (a[i] != 0); i++) {
printf ("%d\n", a[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment