fork download
  1. #include <stdio.h>
  2.  
  3. int Search(int Array[], int head, int tail, int key) {
  4. head = 0;
  5. while (head < tail) {
  6. head++;
  7. if (Array[head] == key) {
  8. return head + 1;
  9. } else {
  10. continue;
  11. }
  12. }
  13. return -1;
  14. }
  15. int main(void) {
  16. int head = 0;
  17. int tail = 6;
  18. int key = 17;
  19. int Array[] = {7, 12, 6, 5, 11, 10, 13};
  20. if (head < tail) {
  21. head++;
  22. if (Search(Array[], head, tail, key) == -1) {
  23. printf("%d와 일치", Search(Array[], head, tail, key));
  24. break;
  25. } else {
  26. printf("검색 실패");
  27. }
  28. }
  29.  
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 9424KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:22:20: error: expected expression before ‘]’ token
   if (Search(Array[], head, tail, key) == -1) {
                    ^
prog.c:23:40: error: expected expression before ‘]’ token
    printf("%d와 일치", Search(Array[], head, tail, key));
                                        ^
prog.c:24:4: error: break statement not within loop or switch
    break;
    ^~~~~
prog.c:19:6: warning: variable ‘Array’ set but not used [-Wunused-but-set-variable]
  int Array[] = {7, 12, 6, 5, 11, 10, 13};
      ^~~~~
stdout
Standard output is empty