4.28.2012

Laporan Praktikum Sorting

Nama : Gatra Mustakim
NIM : 201101004

Program 4.1



Listing Program 4.1

//=================================================
// Name : sorting_praktikum_4_1.cpp
// Author : Gatra Mustakim
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//==================================================

#include
using namespace std;

main()
{
int i, j, imin;
int n, urut;
int tmp;
int arr[50];

cout<<" ++++++++++++++ Program Sorting ++++++++++++++++++ ";
cout<<"\n Selection Sort ";
cout<<"\n ++++++++++++++++++++++++++++++++++++++++++++++++++ ";

cout<<"\n\n Masukkan data yang akan di urutkan : ";
cin>>n;

urut=1;
for(i=0;i cout<<" Masukkan Data Ke : "< cin>>arr[i];
}

for(i=1;i imin=1;
for(j=urut;j if(arr[i] 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;
}
cout<<" Setelah Diurutkan \n";
for(i=0;i {
cout<<"Elemen ke "<
}

cout<<"\n ++++++++++++++++ Terima Kasih ++++++++++++++++++ ";

return 0;
}

Output Program 4.1



============================================================

Program 4.2



Listing Program 4.2

//==================================================
// Name : sortiing_Praktikum_4_2.cpp
// Author : Gatra Mustakim
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//=================================================
#include
using namespace std;

main()
{
int i,j,n;
int tmp;
int Arr[50];

cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++ ";
cout<<"\n PROGRAM SORTING ";
cout<<"\n BUBLE SORT ";
cout<<"\n +++++++++++++++++++++++++++++++++++++++++++++++++";

cout<<"\n\n Masukkan data yang akan diurutken : ";
cin>>n;

for (i=0; i{
cout<<" Masukkan data ke "< cin>>Arr[i];
}
for (i=1; i {
for (j=0; j {
if(Arr[j]>Arr[j+1])
{
tmp = Arr[j];
Arr[j]=Arr[j+1];
Arr[j+1]=tmp;
}
}
}
cout<<"\n Setelah Pengurutan ";
for(i=0; i{
cout<<"\n";
cout<<" Elemen ke "<}

cout<<"\n ================== TERIMA KASIH ======================== ";

return 0;
}

Output Program 4.2




==========================================================

Tidak ada komentar:

Posting Komentar