Advertisement
davegimo

Untitled

Jun 17th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. public static int sommaPari(Albero a, int liv) {
  2.  
  3.     int somma = 0;
  4.    
  5.     if (liv % 2 == 0) {
  6.         somma += a.val();
  7.     }
  8.  
  9.     if (a.sx() != null) {
  10.         somma += sommaPari(a.sx(), liv+1);
  11.     }
  12.  
  13.     if (a.dx() != null) {
  14.         somma += sommaPari(a.dx(), liv+1);
  15.     }
  16.  
  17.     return somma;
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement