#include"stdio.h"
#include"conio.h"
void bubble(int a[],int n){
int temp,itv=0,i,j,k;
for(i=0;i< n;i++){
for(j=0;j< (n-1)-i;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}}
printf("after iteration %d \n",++itv);
for(k=0;k< n;k++){
printf("%d ",a[k]);
}
}
}
void main()
{
int a[20],i,n;
printf("enter the no of elements you want to enter");
scanf("%d",&n);
cout<<"enter the elements";
for(i=0;i< n;i++){
scanf("%d",&a[i]);
}
bubble(a,n);
}
Monday, September 1, 2008
Bubble sort
Posted by Nanya at 11:13 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment