Created
October 26, 2014 01:35
-
-
Save shohan4556/315e7d839a1e2af6bb58 to your computer and use it in GitHub Desktop.
bubble sort algo
This file contains hidden or 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> | |
int main() | |
{ | |
int n=0,i,j,k,ck,data[100]; | |
while(scanf("%d",&n)!=EOF){ | |
for(k=0;k<n;k++) | |
scanf("%d",&data[k]); | |
for(j=0;j<n-1;j++){ | |
for(i=0;i<n;i++){ | |
if(data[i]>data[i+1]){ | |
ck=data[i]; | |
data[i]=data[i+1]; | |
data[i+1]=ck; | |
} | |
} // end child loop | |
}// end parent loop | |
for(i=0;i<n;i++) | |
printf("%d ",data[i]); | |
} // end while loop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment