#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct data{
long nbi;
char nama[30];
char alamat[50];
long telp;};
void main(){
int a, c, n=-1,m;
long tempatnbi, tempattelp;
char b,x;
char tempatNama[20],tempatAlamat[40];
data mhs[2];
while (a!=5){
cout<<"\nMENU UATAMA :";
cout<<"\n\n1. Masukkan biodata";
cout<<"\n2. Tampilkan biodata";
cout<<"\n3. Edit biodata";
cout<<"\n4. Keluar";
cout<<"\n\nMasukkan Pilihan : "; cin>>a;
clrscr();
if(a==1)
{n++;
m=n;}
switch (a){
case 1:{
cout<<"\nMASUKKAN BIODATA";
cout<<"\nNBI: "; cin>>mhs[n].nbi;
cout<<"Nama : "; gets(mhs[n].nama);
cout<<"Alamat : "; gets(mhs[n].alamat);
cout<<"Telepon: "; cin>>mhs[n].telp;
break;}
case 2:
{cout<<"\nBIODATA";
if(n==0)
{cout<<"\n\nDATA BELUM DIMASUKKAN";}
else
{for(int d=0;d<=n;d++)
{for(int e=d;e<=n;e++)
{if(mhs[d].nbi > mhs[e].nbi)
{tempatnbi = mhs[d].nbi;
mhs[d].nbi = mhs[e].nbi;
mhs[e].nbi = tempatnbi;
strcpy(tempatNama,mhs[d].nama);
strcpy(mhs[d].nama,mhs[e].nama);
strcpy(mhs[e].nama,tempatNama);
strcpy(tempatAlamat,mhs[d].alamat);
strcpy(mhs[d].alamat,mhs[e].alamat);
strcpy(mhs[e].alamat,tempatAlamat);
tempattelp = mhs[d].telp;
mhs[d].telp = mhs[e].telp;
mhs[e].telp = tempattelp;}}}}
for(int i=0; i<=n; i++)
{if(mhs[i].nbi!=-1)
{cout<<"\n\nNBI : "<<mhs[i].nbi;
cout<<"\nNama : "<<mhs[i].nama;
cout<<"\nAlamat : "<<mhs[i].alamat;
cout<<"\nTelepon: "<<mhs[i].telp;}}
break;}
case 3:
{cout<<"\nMENGEDIT BIODATA";
cout<<"\n\nMasukkan NBI : "; cin>>c;
int z=0;
for (int j=0; j<=n; j++)
{if (c==mhs[j].nbi)
{cout<<"\nNama : "<<mhs[j].nama;
cout<<"\nAlamat : "<<mhs[j].alamat;
cout<<"\nTelepon: "<<mhs[j].telp;
cout<<"\nNama Baru : "; cin>>mhs[j].nama;
cout<<"\nAlamat Baru : "; cin>>mhs[j].alamat;
cout<<"\nTelepon Baru : "; cin>>mhs[j].telp;
z++;}}
if(z==0)
cout<<"\nDATA TIDAK ADA";
break;}
case 4 :// clrscr();
break;
default :
cout<<"\n\nPILIHAN SALAH";
}
if(a!=5)
{cout<<"\n\nTekan 1 karakter untuk kembali ke menu utama : "; cin>>b;}
clrscr();}
getch();}
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar