Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int pf[] = { 5, 8, -1, -1, 3, 7, -1, 10, -1, -1 };
  4. int fd[] = { -1, -1, 4, -1, 6, 2, -1, -1, -1, 9 };
  5.  
  6. int fct(int radacina){
  7.  
  8. int y = 1;
  9.  
  10. int x = pf[radacina - 1];
  11. if (pf[radacina] == -1){
  12. y = 0;
  13. printf("%d", y);
  14. return y;
  15. }
  16.  
  17. while (x != -1){
  18. x = fd[x-1];
  19. y++;
  20.  
  21. }
  22.  
  23. return y;
  24. }
  25.  
  26. int main(){
  27. int j;
  28. int max = fct(0);
  29. for (j = 1; j < 10; j++){
  30. if (fct(j) > max){
  31. max = fct(i);
  32. }
  33. }
  34. printf("%d", max);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement