fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int array[]={0,1,2,3,4,5,6};
  6.  
  7. int head=0;
  8. int tail=6;
  9. int key=5;
  10.  
  11. int center;
  12.  
  13.  
  14.  
  15. for(;;){
  16.  
  17. if(head<=tail)
  18.  
  19. center=(head+tail)/2;
  20. else
  21. printf("ilchi X")
  22.  
  23. break;
  24.  
  25. if(array[center]==key)
  26.  
  27. printf("key=%d",center);
  28.  
  29. break;
  30.  
  31. else if(array[center]<key)
  32.  
  33. head=center+1
  34.  
  35. else
  36.  
  37. tail=center-1
  38.  
  39. }
  40.  
  41. }
  42.  
  43.  
  44.  
  45.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:23:4: error: expected ‘;’ before ‘break’
    break;
    ^~~~~
prog.c:20:2: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
  else
  ^~~~
prog.c:25:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘else’
   if(array[center]==key)
   ^~
prog.c:25:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
prog.c:29:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
    break;
    ^~~~~
prog.c:31:3: error: ‘else’ without a previous ‘if’
   else if(array[center]<key)
   ^~~~
prog.c:35:3: error: expected ‘;’ before ‘else’
   else
   ^~~~
stdout
Standard output is empty