### Bracketing Search Exercise Example? c++

Is there a really good example for this one?
I've found this one http://www.cplusplus.com/forum/beginner/72178/
, but it's struggling with 1 and 100 and it doesn't use user input(too low, too high).
I created one myself, but it doesn't look good, altough it functions properly and the only mistake is that it guesses 100 in 8, not 7 tries:
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188`` ``````#include #include #include int main() { srand(time(NULL)); int k; k=rand()%101+1; std::cout<<"Think of a number from 1 to 100, now type it and I'll try\n"<< "to guess it(numbers can easily change \n"<< "in your mind, but not in mine): "; int b; std::cin>>b; int h=50; std::cout<<"\nIf I enter a number too high, say: high, if I enter a number which is too low, \n"<< "enter: low and if I guess it, enter: true. Here is my first try: "<>feedback; int t=3; int a=1; do { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else if(feedback[0]=='l'||feedback[0]=='L') { std::cout<>feedback; } else if(feedback[0]=='h'||feedback[0]=='H') { std::cout<>feedback; } } if(t!=0) { if(feedback[0]=='t'||feedback[0]=='T') { t=0; } else { std::cout<<"You picked a wrong number Mr!(Or you just lied to me...)\n"; t=0; a=2; } } } while(t!=0); if(a==1&&h==b) { std::cout<<"Woot, I guessed it!"; } else if(a==2||h!=b) { std::cout<<"This program isn't meant for cheaters, bye!"; } std::cin.ignore(); std::cin.get(); return(0); }``````

Any way to do this shorter and at the same time following the instructions?(Which can be found here: http://www.cplusplus.com/articles/N6vU7k9E/)
Pretty sure I saw one just the other day, but I can't find it. Here's a link to mine:
http://www.cplusplus.com/forum/beginner/73868/#msg395217
Yep, that's it. Thank you!
Topic archived. No new replies allowed.