Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Coding by YoYoLove - girlxitin.com
- contact: traitimbanggia.199x@gmail.com
- */
- #include <stdio.h>
- void swap(int *a,int *b)
- {
- int temp=*a;
- *a=*b;
- *b=temp;
- }
- void bubblesort(int Array[],int n)
- {
- int i,count;
- for(count=0;count<n-1;count++)
- for(i=0;i<n-1-count;i++)
- if(Array[i] > Array[i+1])
- swap(&Array[i],&Array[i+1]);
- }
- void print(int Array[],int n)
- {
- int i;
- for(i=0;i<n;i++){
- printf(" %2d",Array[i]);
- }
- }
- int main()
- {
- int Array[] = {1,5,3,10,1};
- int n = sizeof(Array)/sizeof(Array[0]);
- bubblesort(Array,n);
- print(Array,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement