Advertisement
Mellowlicious

Interval

Jun 24th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1.  
  2.         public int CalculateAmount(int score1, int score2)
  3.         {
  4.             return LookForScoreRight(score2, root) - LookForScoreLeft(score1, root);
  5.  
  6.         }
  7.  
  8.         public int LookForScoreLeft(int score, Gamer gLeaf)
  9.         {
  10.            
  11.             if (score > gLeaf.gScore)
  12.             {
  13.                 if (gLeaf.right != null)
  14.                     return LookForScoreLeft(score, gLeaf.right);
  15.                 else
  16.                 {
  17.                     return FindNormalRank(gLeaf);
  18.                 }
  19.             }
  20.             else
  21.             {
  22.                 if (gLeaf.left != null)
  23.                     return LookForScoreLeft(score, gLeaf.left);
  24.                 else
  25.                 {
  26.                     //if (gLeaf.parent.right==gLeaf)
  27.                     //    return FindNormalRank(gLeaf.parent);
  28.                     //else
  29.                         return FindNormalRank(gLeaf)-1;
  30.                 }
  31.             }
  32.  
  33.         }
  34.         public int LookForScoreRight(int score, Gamer gLeaf)
  35.         {
  36.             if (score < gLeaf.gScore)
  37.             {
  38.                 if (gLeaf.left != null)
  39.                     return LookForScoreRight(score, gLeaf.left);
  40.                 else
  41.                 {
  42.                     return FindNormalRank(gLeaf) - 1;
  43.                 }
  44.             }
  45.             else
  46.             {
  47.                 if (gLeaf.right != null)
  48.                    return LookForScoreRight(score, gLeaf.right);
  49.                 else
  50.                     return FindNormalRank(gLeaf);
  51.             }
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement