Sabtu, 30 Maret 2013

C++ Pencari Record (search)

#include<iostream.h>
#include<string.h>
#include<stdio.h>
main()
{
    int X[100]={1001,1002,1003,1004,1005,1006,1007,1008,1009,1010};
    char cnama[20][20]={"Wanto", "Krisna", "Ganis","Ghifar","Agus",
                                "Ani","Pram","Neneng","Jaka","Jack"};
    char calamat[20][20]={"Jln Jalan","Jln Semen","Jln Stapak", "Jln Gede",
                                    "Jln Rel","Jln sore","Jln Liku","Jln Rued",
                                    "Jln Koplak","Jln jadi"};
    char cgol[20][20]={"A","B","C","D","E","F","G","H","I","J"};
    int i,y,j;
    cout<<"Bismillahirrohmanirrohim"<<endl;
    cout<<"No Induk Yang dicari =";
    cin>>y;
         for (i=0;i<=9;i++)
    {
    if (X[i]==y)
        {
        cout<<"No induk = "<<X[i]<<endl;
        cout<<"Nama = "<<cnama[i]<<endl;
        cout<<"Alamat = "<<calamat[i]<<endl;
        cout<<"Golongan = "<<cgol[i];
        j=i;
        }
    }


            if(i<11)
        cout<<"\nTidak ada "<<y<<" dalam daftar";
          else
                cout<<"\n"<<y<<" ditemukan dalam array ke-"<<j+1;
}

0 komentar:

Posting Komentar