0% found this document useful (0 votes)
25 views1 page

Program Pengurutan Metode Minimum Sort Secara Menaik

This document contains code for sorting an array of numbers in ascending order using the minimum method in C++. The code first takes in N numbers and stores them in an array. It then prints the array before sorting. The sorting process finds the minimum number in the unsorted portion of the array and swaps it with the first element, repeating this until the array is fully sorted. Finally, the sorted array is printed.

Uploaded by

sutrisno
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Program Pengurutan Metode Minimum Sort Secara Menaik

This document contains code for sorting an array of numbers in ascending order using the minimum method in C++. The code first takes in N numbers and stores them in an array. It then prints the array before sorting. The sorting process finds the minimum number in the unsorted portion of the array and swaps it with the first element, repeating this until the array is fully sorted. Finally, the sorted array is printed.

Uploaded by

sutrisno
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/* Program Pengurutan Metode Minimum Sort

Pengurutan Secara Menaik


Nama File : Lat_Sorting_05a */

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int Nilai[20];
int i, j, N, l;
int temp, Imin;
cout<<"Masukkan Banyak Bilangan : ";
cin>>N;
for(i=0; i<N; i++)
{
cout<<"Elemen ke-"<<i<<" : ";
cin>>Nilai[i];
}

//Proses Cetak Sebelum diurutkan


cout<<"\nData sebelum diurut : ";
for(i=0; i<N; i++)
cout<<setw(3)<<Nilai[i];

//Proses Pengurutan
for(i=0; i<=N-2; i++)
{
Imin = i;
for(j=i+1; j<N; j++)
{
if(Nilai[j] < Nilai[Imin]);
Imin = j;
}
temp = Nilai[i];
Nilai[i] = Nilai[Imin];
Nilai[Imin] = temp;
cout<<endl;
for(l=0; l<N; l++)
cout<<setw(3)<<Nilai(l);
}
cout<<"\nData Setelah di urut : ";
for(i=0; i<N; i++)
cout<<setw(3)<<Nilai[i];
getch();
}

You might also like