Bubble Sort
I include the the function only, and used more variables for the understand of beginners.For the Algorithm look in Tutorials.
/*Be for you use bubble sort you should enter the data into array, any write a another function to output it, If you see it difficult comment so i can give you all the code.*/
#include
#include
#difine N 10
int V[N];
void bsort(int V[N]);
void input(int V[N]);
void output(int V[N]);
void main()
{
input(V);
bsort(V);
output(V);
getch();
}
void bsort(int b[N])
{
int k=0,c=0,j,t,e1,e2;
while(c
{
j=0; t=1;
do
{ e1=b[j]; e2=b[t];
if(e1>e2)
{ k=b[j];
b[j]=b[t];
b[t]=k; }
j++;
t++;
}
while(j
c++;
}
printf("sorting done.....\n Press Enter to Return to menu\n");
getch();
}

0 Responses to Bubble Sort
Something to say?