hello
could some one describe me how it works
i could not understand clearly
---------------------------------------
/* now short them using a buble sort */
for (a=1; a<count; ++a)
for (b=count-1; b>=a; --b){
/* compair adjacent elements */
if (item[b-1] > item[b]){
/* excage elements */
t= item[b-1];
item[b-1] = item[b];
item[b]=t;
---------------------------------------
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int item[100];
int a, b, t;
int count;
/*read in numbers*/
printf("how many numbers?");
scanf("%d", &count);
for(a=0; a<count; a++) scanf("%d", &item[a]);
/* now short them using a buble sort */
for (a=1; a<count; ++a)
for (b=count-1; b>=a; --b){
/* compair adjacent elements */
if (item[b-1] > item[b]){
/* excage elements */
t= item[b-1];
item[b-1] = item[b];
item[b]=t;
}
}
/* desplay stored list */
for (t=0; t<count; t++) printf("%d\t", item[t]);
return 0;
}