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