Contoh Program C++ Searching

Program : C++
Specific  : Searching

========================================


#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
main()
{
       char npm[500][10];
       char nm[500][20];
       char kls[500][3];
       char npm_cari [10];
       int ketemu=0, i=0, jd=0, no=0;
       char adm='Y';

       while (adm=='Y')
       {
                clrscr();
                jd++;
                gotoxy (10,5) ; cout <<"Input Data Mahasiswa";
                gotoxy (10,7) ; cout <<"Data Mahasiswa ke-" << (i+1);
                gotoxy (10,8) ; cout <<"NPM   = ";
                gotoxy (10,9) ; cout <<"Nama  = ";
                gotoxy (10,10); cout <<"Kelas = ";
                gotoxy (10,12); cout <<"Ada Data Mahasiswa Lainnya [Y/T] = ";
                gotoxy (18,8); gets (npm[i]);
                gotoxy (18,9); gets (nm[i]);
                gotoxy (18,10); gets (kls[i]);
                i++;
                gotoxy (45,12); cin >> adm;
       }
       // Menampilkan seluruh data yg diinputkan
       clrscr();
       gotoxy (10,2); cout << "Daftar Mahasiswa TI Angkatan 2012";
       gotoxy (2,4); cout << "------------------------------------------------";
       gotoxy (2,5); cout << "| No. |   NPM    |       Nama          | Kelas |";
       gotoxy (2,6); cout << "------------------------------------------------";
        //                    234567890123456789012345678901234567890123456789
        //                            1         2         3         4
       for (i=0; i<jd; i++)
       {
               no=no+1;
               gotoxy (2,6+no); cout << "|     |          |                     |       |";
               gotoxy (5,6+no); cout << no << ".";
               gotoxy (10,6+no); cout << npm[i];
               gotoxy (21,6+no); cout << nm[i];
               gotoxy (45,6+no); cout << kls[i];

       }
       gotoxy (2,7+no); cout << "------------------------------------------------";
       getch();

       // Proses Searching

       i=0;
       clrscr();
       gotoxy (20,10); cout << "Mencari Data Mahasiswa";
       gotoxy (20,12); cout << "Inputkan NPM = "; cin >> npm_cari;
       while (i<jd && ketemu==0)
       {
            if(strcmp(npm[i],npm_cari)==0)
               ketemu=1;
            else
               i++;
       }

       if (ketemu)
       {
           gotoxy(20,14); cout << "Data Mahasiswa tsb berada pada indeks ke-" << i;
           gotoxy(20,16); cout << "Nama  = " << nm[i];
           gotoxy(20,17); cout << "Kelas = " << kls[i];
       }
       else
       {    gotoxy(20,14); cout << "Data Mahasiswa tsb tidak ditemukan"; }
       getch();
}













.