Last active
February 1, 2021 14:48
-
-
Save robertodormepoco/d1907c77163030fe0860b9fa5114e8dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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