Jawabanmu

2014-07-10T20:33:58+07:00
Berikut contoh codingnya : #include "conio.h"#include "stdio.h"int main() {int i, j, iMin;int n, Urut;int Tmp, code;int Arr[100];do {printf("=====================================\n");printf("| Pilihan Program Sorting |\n");printf("=====================================\n");printf("| 1. Selection Sorting (Ascending) |\n");printf("| 2. Selection Sorting (Descending) |\n");printf("| 3. Keluar . . . |\n");printf("=====================================\n\n");printf("Masukan Pilihan Anda : ");scanf("%d", &code);switch (code) {case 1 :printf("\nInputkan banyak data yang akan diurutkan : ");scanf("%i", &n);Urut = 1;for(i = 0; i < n; i++) {printf("Masukan data ke %i : ", i + 1);scanf("%i", &Arr[i]);}for(i = 0; i < n - 1; i++) {iMin = i;for(j = Urut; j < n; j++) {if(Arr[j] < Arr[iMin]) {iMin = j;if(Arr[i] != Arr[iMin]) {Tmp = Arr[i];if(Arr[i] > Arr[iMin]) {Arr[i] = Arr[iMin];Arr[iMin] = Tmp;}}}}Urut = Urut + 1;}printf("\nSetelah Pengurutan\n");for(i = 0; i < n; i++) {printf("Elemen ke %i : %i\n", i + 1, Arr[i]);}getch();break;