Rizki Hayunanda's Blog

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <string.h>
void main(){
struct pegawai{
char nip[10], nama[30], kodestatus , kodejab, titip1[30],titip2[10],titip3,titip4;
int gapok, janak, tunj, tot, tunj_istri,titip5;
bool pilih;
};
pegawai pgw[100];
int i,j, n;

cout<<“\t\t\t============================\n”;
cout<<“\t\t\tDATA KARYAWAN PT SIOMAY SOTO\n”;
cout<<“\t\t\t============================\n\n”;

cout<<“\nMasukkan jumlah karyawan     :”; cin>>n;

cout<<“\nKeterangan Kode Status:\n”;
cout<<“A. Untuk status menikah\n”;
cout<<“B. Untuk status single\n”;

cout<<“\nKeterangan Kode Jabatan:\n”;
cout<<“S. Untuk jabatan Sekretaris\n”;
cout<<“D. Untuk jabatan Direktur\n”;
cout<<“M. Untuk jabatan Manager\n”;
cout<<“K. Untuk jabatan Karyawan\n”;

cout<<“\nINPUT DATA KARYAWAN\n”;
cout<<“===================\n”;

for(i=0; i<n; i++){
cout<<“\nDATA PEGAWAI “<<(i+1)<<“\n”;
cout<<“Nama             :”; cin>>pgw[i].nama;
cout<<“NIP              :”; cin>>pgw[i].nip;
cout<<“Kode Status      :”; cin>>pgw[i].kodestatus;
cout<<“Kode Jabatan     :”; cin>>pgw[i].kodejab;
cout<<“Jumlah Anak      :”; cin>>pgw[i].janak;
}

for(i=0; i<(n-1); i++){
for(j=(i+1); j<n; j++){
if (strcmp (pgw[i].nama,pgw[j].nama)>0){
strcpy (pgw[i].titip1,pgw[i].nama);
strcpy (pgw[i].nama,pgw[j].nama);
strcpy (pgw[j].nama,pgw[i].titip1);

strcpy (pgw[i].titip2,pgw[i].nip);
strcpy (pgw[i].nip,pgw[j].nip);
strcpy (pgw[j].nip,pgw[i].titip2);

pgw[i].titip3=pgw[i].kodestatus;
pgw[i].kodestatus=pgw[j].kodestatus;
pgw[j].kodestatus=pgw[i].titip3;

pgw[i].titip4=pgw[i].kodejab;
pgw[i].kodejab=pgw[j].kodejab;
pgw[j].kodejab=pgw[i].titip4;

pgw[i].titip5=pgw[i].janak;
pgw[i].janak=pgw[j].janak;
pgw[j].janak=pgw[i].titip5;
}}}

cout<<“\nOUTPUT DATA PEGAWAI\n”;
cout<<“====================\n”;
for(i=0; i<n; i++){
cout<<“\nDATA PEGAWAI “<<(i+1);
cout<<“\nNama             :”<<pgw[i].nama;
cout<<“\nNIP              :”<<pgw[i].nip;
cout<<“\nKode…

View original post 256 more words

This entry was posted in knowladge. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s