Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int A, R, T;
- string key;
- bool ada=false;
- string data[10]={"ibnu bert", "no name", "pain lover", "hak bert", "dark clown", "phantom sec", "buiten zorg", "xai syndicate", "secrash team", "tersakiti crew"};
- A=0;
- R=8;
- cout << "Ketikan nama: ";
- getline(cin, key);
- do
- {
- T = (A+R)/2;
- if (data[T] == key)
- {
- ada = true;
- } else if (data[T] > key)
- {
- R = T - 1;
- } else
- {
- A = T + 1;
- }
- } while (A <= R && ada == false);
- if (ada == true)
- {
- cout << "nama" << " " << key << " " << "ditemuan di ";
- for (int a = 0; a < 10; a++)
- {
- if (key == data[a])
- {
- cout << "Index ke = " << a << endl;
- }
- }
- } else
- {
- cout << "tidak ada" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement