Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var list = [5, 4, 3, 5, 2, 50, 8, 10, 300]
  2.  
  3. func findMin(numbers: NSArray) {
  4.  
  5. var minValue = numbers[0]
  6. var isSmallest: Bool
  7.  
  8. for i in 0...numbers.count {
  9. isSmallest = true
  10. for j in 0...numbers.count {
  11. if i > j {
  12. isSmallest = false
  13. }
  14. }
  15.  
  16. if isSmallest {
  17. minValue = i
  18. }
  19.  
  20. }
  21. print("Smallest value in the list is (minValue)")
  22. }
  23.  
  24. findMin(numbers: list as NSArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement