fork download
  1. int l = 0;
  2. int r = 1000;
  3. // l and r denote our current bounds: we know that l <= x <= r
  4. while(l<r) {
  5. // we will ask about the number in the middle
  6. int m = (l+r)/2;
  7. // note: this is an integer division, thus e.g., for l=0, r=1 we get m=1/2=0
  8. if(x <= m)
  9. r = m;
  10. else
  11. l = m+1;
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:1: error: expected unqualified-id before ‘while’
 while(l<r) {
 ^~~~~
stdout
Standard output is empty