davegimo

Untitled

Jun 17th, 2019
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data