Guest User

recursive 3a

a guest
Dec 31st, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int array[3] = {0,0,1};
  5.                
  6. bool find_1(int j)
  7. {
  8.     if(j < 3)
  9.     {
  10.         if(array[j] == 1)  
  11.             return 1;
  12.         else
  13.             return find_1(j+1);
  14.     }
  15.     else
  16.     {
  17.         return 0;  
  18.     }
  19. }
  20.  
  21. int main()
  22. {
  23.    if(find_1(0))
  24.     printf("Got Gold\n");
  25.    else
  26.     printf("Got Nothing\n");
  27.    system("pause");
  28.    return 0;    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment