Coding :
#include <stdio.h> #include <stdlib.h> void tukarNilai(int *intA, int intB); int main() { int listAngka[20]={1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2}; int swap, urutan; do{ swap=0; for(urutan = 0; urutan <19; urutan++){ if(listAngka[urutan] < listAngka[urutan+1]){ tukarNilai(&listAngka[urutan], &listAngka[urutan+1]); swap=1; } } }while(swap == 1); for(urutan=0; urutan < 20; urutan++){ printf("Nilai : %d, \n", listAngka[urutan]); } system("pause"); } void tukarNilai(int *intA, int *intB){ int tInt = * intA; *intA = *intB; *intB = tInt; }Video :
No comments:
Post a Comment