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