fork download
  1. #include<stdio.h>
  2. char* Divide(int arr[],int l,int r,int key)
  3. {
  4. int m=(l+r)/2;
  5. if(l==r)
  6. {
  7. if(key==arr[m])
  8. return "Found";
  9. else
  10. return "Not Found";
  11. }
  12. else
  13. {
  14. if(key==arr[m])
  15. return "Found";
  16. else if(key>arr[m])
  17. return Divide(arr,m+1,r,key);
  18. else
  19. return Divide(arr,l,m,key);
  20. }
  21. }
  22. int main()
  23. {
  24. int arr[]={1,2,3,4,5,6,7,8};
  25. int n=sizeof(arr)/sizeof(arr[0]);
  26. char* result=Divide(arr,0,n-1,10);
  27. printf("%s\n",result);
  28. return 0;
  29. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Not Found