Tempat Hacking dan Cracking

Algoritma Sorting Pada Pemrograman C++

Algoritma Sorting Pada Pemrograman C++

Kali ini saya akan nge post contoh program sorting pada pemrograman c++, buat user dapat membaca dan memahami logika nya



#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. Bubble Sorting (Ascending) |\n");
printf("| 4. Bubble Sorting (Descending) |\n");
printf("| 5. Insertion Sorting (Ascending) |\n");
printf("| 6. Insertion Sorting (Descending) |\n");
printf("| 7. 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 < i =" 0;" imin =" i;" j =" Urut;" imin =" j;" tmp =" Arr[i];"> Arr[iMin]) {
Arr[i] = Arr[iMin];
Arr[iMin] = Tmp;
}
}
}
}
Urut = Urut + 1;
}
printf("\nSetelah Pengurutan\n");
for(i = 0; i < urut =" 1;" i =" 0;" i =" 0;" imin =" i;" j =" Urut;"> Arr[iMin]) {
iMin = j;
if(Arr[i] != Arr[iMin]) {
Tmp = Arr[i];
if(Arr[i] < urut =" Urut" i =" 0;" i =" 0;" i =" 1;" j =" 0;"> Arr[j + 1]) {
Tmp = Arr[j];
Arr[j] = Arr[j + 1];
Arr[j + 1] = Tmp;
}
}
}
printf("\nSetelah Pengurutan\n");
for(i = 0; i < i =" 0;" i =" 1;" j =" 0;" tmp =" Arr[j];" i =" 0;" i =" 0;" i =" 1;" tmp =" Arr[i];" j =" i">= Tmp && j > 0) {
Arr[j + 1] = Arr[j];
j = j - 1;
}
if(Tmp >= Arr[j]) {
Arr[j + 1] = Tmp;
} else {
Arr[j + 1] = Arr[j];
Arr[j] = Tmp;
}
}
printf("\nSetelah Pengurutan\n");
for(i = 0; i < i =" 0;" i =" 1;" tmp =" Arr[i];" j =" i"> 0) {
Arr[j + 1] = Arr[j];
j = j - 1;
}
if(Tmp <= Arr[j]) { Arr[j + 1] = Tmp; } else { Arr[j + 1] = Arr[j]; Arr[j] = Tmp; } } printf("\nSetelah Pengurutan\n"); for(i = 0; i <>=1 && code <= 6); getch(); }



share this article to: Facebook Twitter Google+ Linkedin Technorati Digg
Posted by Mubasir Alamsah, Published at 10:40 and have 0 komentar

No comments:

Post a Comment

Blog ini merupakan Blog Dofollow, karena beberapa alasan tertentu, sobat bisa mencari backlink di blog ini dengan syarat :
1. Tidak mengandung SARA
2. Komentar SPAM dan JUNK akan dihapus
3. Tidak diperbolehkan menyertakan link aktif
4. Berkomentar dengan format (Name/URL)