Advertisement
Guest User

recursion

a guest
Mar 4th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int f( int n, char start, char help, char end);
  4.  
  5. int main()
  6. {
  7. printf("Hello, World!\n");
  8.  
  9. f(3, 'a', 'b', 'c');
  10.  
  11. return 0;
  12. }
  13.  
  14. int f( int n, char start, char help, char end){
  15. if ( n==0 )
  16. return 0;
  17.  
  18. f( n-1, start, end, help);
  19.  
  20. printf("prebacujemo iz - %c - u kulicu - %c -\n", start, end);
  21.  
  22. f( n-1, help, start, end);
  23.  
  24. return 0;
  25. }
  26.  
  27.  
  28. /*
  29. if (n>0 && n%2 == 1){
  30. f( n-1, start, help, end );
  31. }
  32. else if (n>0 && n%2 == 0)
  33. f( n-1, help, start, end );
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement