Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import UIKit
  2.  
  3. var myString = "Ala ma kota!"
  4. var myInteger = 12
  5. var myDouble = 12.21
  6.  
  7. let myConstantInteger: Int = 12
  8. let myConstantDouble: Double = 12.21
  9. let myConstantString: String = "Ala ma kota!"
  10.  
  11. var concatenateString = myString + " " + String(myInteger)
  12. var concatenateString2 = "\(myString) \(myInteger)"
  13.  
  14. var array = [1,2,3,4,5,6,7]
  15. var dictionary = ["gwe":"one", "rty":"two", "uio":"three"]
  16.  
  17. var lottoResults = ["29-11-14":[4, 5, 21, 30, 31, 49], "27-11-14": [5, 8, 10, 19, 23, 40]]
  18.  
  19. var emptyDictionary = [Character: Int]()
  20. let letters = ["A","B","C","D","E","F","G","H","I","J"]
  21. var j = 1
  22. for i in letters{
  23. emptyDictionary[Character(i)] = j
  24. j += 1
  25. }
  26. print(emptyDictionary)
  27.  
  28. for i in lottoResults{
  29. print(i.key)
  30. for j in i.value{
  31. print("- \(j)")
  32. }
  33. }
  34.  
  35. func nwd(a: Int, b: Int) -> Int{
  36. if(b == 0){
  37. return a
  38. } else {
  39. return nwd(a: b, b: (a - b * Int(floor(Double(a)/Double(b)))))
  40. }
  41.  
  42. }
  43.  
  44. print (nwd(a: 30, b: 45))
  45.  
  46. func nwd2(a: Int, b: Int) -> (Int,Int,Int){
  47. var result = 0
  48. if(b == 0){
  49. result = a
  50. } else {
  51. result = nwd2(a: b, b: (a - b * Int(floor(Double(a)/Double(b)))))
  52. }
  53. return(result, a/result, b/result)
  54.  
  55. }
  56.  
  57. print (nwd2(a:30,b:45))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement