Contoh Program sort, binary, sequential pada C++ Ini adalah program sorting paling lengkap. contoh program sort c++ : #include #include int data[100],data2[100]; int n; void tukar(int a,int b) { int t; t = data[b]; data[b] = data[a]; data[a] = t; } void bubble_sort() { for(int i=1;i { for(int j=n-1;j>=i;j–) { if(data[j] } } cout<<”bubble sort selesai!”< } void exchange_sort() { for (int i=0; i { for(int j = (i+1); j { if (data [i] > data[j]) tukar(i,j); } } cout<<”exchange sort selesai!”< } void selection_sort() { int pos,i,j; for(i=0;i { pos = i; for(j = i+1;j { if(data[j] < data[pos]) pos = j; } if(pos != i) tukar(pos,i); } cout<<”selection sort selesai!”< } void insertion_sort() { int temp,i,j; for(i=1;i { temp = data[i]; j = i -1; while(data[j]>temp && j>=0) { data[j+1] = data[j]; j–; } data[j+1] = temp; } cout<<”insertion sort selesai!”< } void QuickSort(in
Ingin Mengetahui Lebih lanjut..?