#define MAXSIZE 20
void sort(int[],int);
void main (void)
{
static int list[MAXSIZE];
int size=0;
int dex;
do
{
printf("Type Number: ");
scanf("%d",&list[size]);
}
while(list[size++] != 0);
sort(list,--size);
for(dex=0;dex<size;dex++)
printf("%d\n",list[dex]);
}
void sort(int[list],int size)
{
int out,in,temp;
for(out=0;out<size-1;out++)
for(in=out+1;in<size;in++)
if(list[out]>list[in])
{
temp = list[in];
list[in] = list[out];
list[out] = temp;
}
}
Output:
Type Number: 46
Type Number: 25
Type Number: 73
Type Number: 58
Type Number: 33
Type Number: 18
Type Number: 0
18
25
33
46
58
73
If you have any question, you ask me freely!
void sort(int[],int);
void main (void)
{
static int list[MAXSIZE];
int size=0;
int dex;
do
{
printf("Type Number: ");
scanf("%d",&list[size]);
}
while(list[size++] != 0);
sort(list,--size);
for(dex=0;dex<size;dex++)
printf("%d\n",list[dex]);
}
void sort(int[list],int size)
{
int out,in,temp;
for(out=0;out<size-1;out++)
for(in=out+1;in<size;in++)
if(list[out]>list[in])
{
temp = list[in];
list[in] = list[out];
list[out] = temp;
}
}
Output:
Type Number: 46
Type Number: 25
Type Number: 73
Type Number: 58
Type Number: 33
Type Number: 18
Type Number: 0
18
25
33
46
58
73
If you have any question, you ask me freely!
0 comments:
Post a Comment