Skip to content

Instantly share code, notes, and snippets.

@anugrahbsoe
Created August 29, 2015 04:11
Show Gist options
  • Save anugrahbsoe/562238ec1dabca9f0d11 to your computer and use it in GitHub Desktop.
Save anugrahbsoe/562238ec1dabca9f0d11 to your computer and use it in GitHub Desktop.
belajar bsort
#include "stdio.h"
#define n 10
void main()
{
int A[n] = {15,10,7,22,17,5,12,8,15,10};
int X, I, K;
printf("Sebelum di-sort\n");
for (I=0; I <= n-1; I++)
printf("%3i", A[I]);
printf("\n");
K=0;
while(K<=n-2)
{
I=0;
while(I<=n-1 - K)
{
if (A[I] > A[I+1])
{
X = A[I];
A[I] = A[I+1];
A[I+1] = X;
}
I++;
}
K++;
}
printf("Sesudah di-sort\n");
for (I=0; I<= n-1; I++)
printf("%3d", A[I]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment