#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int selection(){
int data[]= { 5, 1, 91, 4, 26, 7, 10, 8, 2 };
int tmp;
for (int i = 0; i < 9 -1; i++)
{
for (int j = i+1; j < 9; j++)
{
if (data[i] > data[j])
{
tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
cout<<"\nData yang telah di urutkan \t:";
for( int i = 0; i < 9; i++)
cout << data[i] << " ";
return;
}
int main(int argc, char** argv) {
int data [] = { 5, 1, 91, 4, 26, 7, 10, 8, 2 };
cout<<"\tSELECTION SORT\n\n";
cout << "Data yang akan di urutkan \t:";
for( int i = 0; i < 9; i++)
cout << data[i] << " ";
cout << endl;
cout << selection();
return 0;
}
0 komentar:
Posting Komentar