Created
August 29, 2015 04:11
-
-
Save anugrahbsoe/562238ec1dabca9f0d11 to your computer and use it in GitHub Desktop.
belajar bsort
This file contains 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" | |
#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