#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <iomanip>
#include <windows.h>
using namespace std;
main ()
{
char nama[40];
char nim[15];
cout << "||*************************************************||\n";
cout << "|| Masukan nama & nim untuk Log in ||\n";
cout << "||*************************************************||\n\n";
cout<<"Masukan Nama : "; cin>>nama;
cout<<"Masukan NIM : "; cin>>nim;
if (strcmp(nama,"Husni") ==0 && strcmp(nim,"191011400011") ==0)
{
cout<<"\n___________________________\n\n";
cout<<" Login Berhasil " << endl;
cout<<"___________________________\n\n";
cout<<" Tekan ENTER untuk Lanjutkan \n\n";
getch();
}
else
{
cout<<"\n_________________________________\n\n";
cout<<"Nama & NIM yang di masukan salah"<<endl;
cout<<"_________________________________\n\n";
}
menu:
system("cls");
int data[15]={24,11,16,28,26,43,32,20,90,50,55,72,75,85,25};
int i,u,maks,j,t,min;
int pilihan;
cout<<"--------Menu----------\n";
cout<<" 1.Metode Maximum Sort (Pengurutan secara menaik)\n";
cout<<" 2.Metode Maximum Sort (Pengurutan secara menurun)\n";
cout<<" 3.Metode Minimum Sort (Pengurutan secara menaik)\n";
cout<<" 4.Metode Minimum Sort (Pengurutan secara menurun)\n";
cout<<" 5.Exit\n";
cout<<"----------------------\n";
cout<<"Masukan Pilihan anda : ";cin>>pilihan;
cout<<endl;
switch (pilihan)
{
case 1:
cout<<"Data sebelum di urut\n\n";
for (i=0;i<15;i++)
{
cout<<setw(3)<<data[i]<<" ";
}
cout<<endl;
//Proses Pengurutan
u=15-1;
for(i=0;i<=15-2;i++)
{
maks=0;
for(j=1;j<=u;j++)
{
if(data[j]>data[maks])
maks=j;
}
t=data[u];
data[u]=data[maks];
data[maks]=t;
u--;
cout<<endl;
for(int a=0;a<15;a++)
cout<<setw(3)<<data[a];
}
cout<<"\n\nData setelah di urut : \n\n";
for(i=0;i<15;i++)
cout<<setw(3)<<data[i];
cout<<endl<<endl;
lanjut:
cout<<"Tekan ENTER untuk kembali ke menu";
getch();
goto menu;
case 2:
cout<<"Data sebelum di urut\n\n";
for (i=0;i<15;i++)
{
cout<<setw(3)<<data[i]<<" ";
}
cout<<endl;
//Proses Pengurutan
u=15-1;
for(i=0;i<=15-2;i++)
{
maks=i;
for(j=i+1;j<=u;j++)
{
if(data[j]>data[maks])
maks=j;
}
t=data[i];
data[i]=data[maks];
data[maks]=t;
cout<<endl;
for(int a=0;a<15;a++)
cout<<setw(3)<<data[a];
}
cout<<"\n\nData setelah di urut : \n\n";
for(i=0;i<15;i++)
cout<<setw(3)<<data[i];
cout<<endl<<endl;
goto lanjut;
getch();
goto menu;
case 3:
cout<<"Data sebelum di urut\n\n";
for (i=0;i<15;i++)
{
cout<<setw(3)<<data[i]<<" ";
}
cout<<endl;
//Proses Pengurutan
for(i=0;i<=15-2;i++)
{
min=i;
for(j=i+1;j<15;j++)
{
if(data[j]<data[min])
min=j;
}
t=data[i];
data[i]=data[min];
data[min]=t;
cout<<endl;
for(int a=0;a<15;a++)
cout<<setw(3)<<data[a];
}
cout<<"\n\nData setelah di urut : \n\n";
for(i=0;i<15;i++)
cout<<setw(3)<<data[i];
cout<<endl<<endl;
goto lanjut;
getch();
goto menu;
case 4:
cout<<"Data sebelum di urut\n\n";
for (i=0;i<15;i++)
{
cout<<setw(3)<<data[i]<<" ";
}
cout<<endl;
//Proses Pengurutan
u=15-1;
for(i=0;i<=15-2;i++)
{
min=0;
for(j=1;j<=u;j++)
{
if(data[j]<data[min])
min=j;
}
t=data[u];
data[u]=data[min];
data[min]=t;
cout<<endl;
u--;
for(int a=0;a<15;a++)
cout<<setw(3)<<data[a];
}
cout<<"\n\nData setelah di urut : \n\n";
for(i=0;i<15;i++)
cout<<setw(3)<<data[i];
cout<<endl<<endl;
goto lanjut;
getch();
goto menu;
case 5:
exit(0);
}
}
Tidak ada komentar:
Posting Komentar