Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hastwoLower::Int->Int->Int->Int->Int->Bool
  2. hastwoLower a b c d e | (a <= b) && (a <= c) && (a <= d) && (a <= e) == True = False
  3.  
  4.                       | (a <= b && a <= c) ||  (a <= b && a <= d) || (a <= b && a <= e) ||
  5.                         (a <= c && a <= d) || (a <= c && a <= e) ||
  6.                         (a <= d && a <= e) == True = True
  7.                      
  8.                       | otherwise  = False
  9.  
  10. hastwoUpper::Int->Int->Int->Int->Int->Bool
  11. hastwoUpper a b c d e | (a >= b) && (a >= c) && (a >= d) && (a >= e) == True = False
  12.  
  13.                       | (a >= b && a >= c) ||  (a >= b && a >= d) || (a >= b && a >= e) ||
  14.                         (a >= c && a >= d) || (a >= c && a >= e) ||
  15.                         (a >= d && a >= e) == True = True
  16.                      
  17.                       | otherwise  = False
  18.  
  19. mediana::Int->Int->Int->Int->Int->Int
  20. mediana a b c d e | hastwoLower a b c d e && hastwoUpper a b c d e == True = a
  21.                   | hastwoLower b c d e a && hastwoUpper b c d e a == True = b
  22.                   | hastwoLower c b a d e && hastwoUpper c b a d e == True = c
  23.                   | hastwoLower d b c a e && hastwoUpper d b c a e == True = d
  24.                   | hastwoLower e b c d a && hastwoUpper e b c d a == True = e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement