Monday, April 16, 2012
SEQUENTIAL SEARCHING
#include <iostream.h>
#include <conio.h>
void main()
{
int i;
int cari,ketemu;
int A[100] ;
cout<<"* PROGRAM SEQUENTIAL SEARCHING *\n";
cout<<"--------------------------------\n";
cout<<"Inputlah 7 buah data!\n\n";
for (i=1;i<=7;i++)
{
cout<<"Data ke-"<<i<<" = ";
cin>>A[i] ;
}
cout<<endl;
cout<<"Input bilangan yang dicari : ";
cin>>cari;
ketemu=0;
for(i=0;i<=7;i++)
{
if (A[i]==cari)
{
ketemu=1;
cout<<"Data ada pada indeks ke-"<<i<<endl;
}
}
if (ketemu==0){
cout<<"Data tidak ditemukan";
}
getch();
}
Labels:
Struktur Data
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment