Jumat, 27 April 2012

Laporan Praktikum Modul 4 Sorting (Novian Adi P) (201101029)

Laporan Praktikum Modul 4 Sorting
Disusun oleh :
Novian Adi Prasetyo
201101029

Dosen
Yosef Murya Kusuma Ardhana, S.T


JURUSAN SISTEM INFORMASI
SEKOLAH TINGGI ILMU KOMPUTER (STIKOM)
“YOS SUDARSO”
PURWOKERTO
2012


                        ------------------------

>> Program Praktikum 4.1


Listing Program :

#include <iostream>
using namespace std;

main ()
{
       int i,j,iMin;
       int n, Urut;
       int Tmp;
       int Arr[50];

       cout<<"Masukan data yang akan diurutkan : ";
       cin>>n;

       Urut=1;
       for(i=0;i<n;i++)
       {
             cout<<"Masukan data ke "<<i+1<<" : ";
             cin>>Arr[i];
       }

       //rumus sorting
       for(i=0;i<n-1;i++)
             {
             iMin=i;

                    for(j=Urut;j<n;j++)
                    {
                           if(Arr[j]<Arr[iMin])
                           {
                                 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 Pengurutan\n";
                    for(i=0;i<n;i++)
                    {
                           cout<<"Elemen ke "<<i+1<<" : "<<Arr[i]<<endl;
                    }
                    return 0;

}


Output Program :


















>> Program Praktikum 4.2


Listing Program :

#include <iostream>
using namespace std;

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

     cout<<"Inputkan banyak data yang akan di urutkan : ";
     cin>>n;
     for (i=0;i<n;i++)
     {
         cout<<"Masukan data ke "<<i+1<<": ";
         cin>>Arr[i];
     }
         for (i=1;i<n;i++)
         {
             for (j=0;j<n-1;j++)
             {
                 if(Arr[j]>Arr[j+1])
                 {
                                    Tmp=Arr[j];
                                    Arr[j]=Arr[j+1];
                                    Arr[j+1]=Tmp;
                 }
             }
         }
                                    cout<<"Setelah Pengurutan\n";
                                    for(i=0;i<n;i++)
                                    {
                                    cout<<"Elemen ke "<<i+1<<" : "<<Arr[i]<<"\n";
                                    }
return 0;
}





Output Program :





























>> Program Praktikum 4.3


Listing Program :






Output Program :





>> Program Praktikum 4.4


Listing Program :






Output Program :





Tidak ada komentar:

Posting Komentar