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