Guest User

Untitled

a guest
Feb 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. func getMax<T: Comparable>(dizi a: [T]) -> T
  2. {
  3. var max = a[0]
  4.  
  5. for i in 1..<a.count {
  6. if max < a[i] {
  7. max = a[i]
  8. }
  9. }
  10.  
  11. return max
  12. }
  13.  
  14. let sayiDizisi = [97, 34, 1, 129, 444]
  15. getMax(dizi: sayiDizisi) // 444
  16.  
  17. let sayiDizisi2 = [97.0, 97.12, 1, 97.88, 97.9]
  18. getMax(dizi: sayiDizisi2) // 97.90000000000001
Add Comment
Please, Sign In to add comment