namereq

countHigher

Jun 18th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.60 KB | None | 0 0
  1. def countHigher(ar, standard)
  2.     n = 0
  3.     for i in 0 .. ar.size - 1 do
  4.         if ar[i] > standard then
  5.         n += 1
  6.         end
  7.     end
  8.     return n
  9. end
  10.  
  11. ################# Main #################
  12.  
  13. ar = [176.5,173.6,178.7,168.6,173.2,179.5,177.9,168.0,176.8,181.7,175.4,179.7,
  14.  
  15. 170.4,171.0,166.7,177.4,175.9,174.7,170.3,173.2,177.1,178.7,174.3,172.9,
  16.  
  17. 176.0,184.9,181.5,177.1,161.9,176.2,179.7,170.3,182.7,166.4,171.7,180.8,
  18.  
  19. 181.3,182.4,172.8,172.9,180.9,189.9,179.2,184.2,170.2,185.3,173.9,183.3,
  20.  
  21. 183.5]
  22.  
  23. standard = 171.0
  24.  
  25. higher = countHigher(ar,standard)
  26. print(standard , " cm higher " , higher , " person. ")
Advertisement
Add Comment
Please, Sign In to add comment