vadim_sharaf

Untitled

Mar 6th, 2023
1,651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.19 KB | None | 0 0
  1. //1 задание
  2. var const1 = "ufb4"
  3. var const2 = "48"
  4. var const3 = "h4"
  5. var const4 = "42"
  6. var const5 = "0384"
  7.  
  8. let num1 = Int(const1) ?? 0
  9. let num2 = Int(const2) ?? 0  
  10. let num3 = Int(const3) ?? 0
  11. let num4 = Int(const4) ?? 0
  12. let num5 = Int(const5) ?? 0
  13. let sum = num1 + num2 + num3 + num4 + num5
  14.  
  15. let c1 = Int(const1) != nil ? String(Int(const1)!) : "nil"
  16. let c2 = Int(const2) != nil ? String(Int(const2)!) : "nil"
  17. let c3 = Int(const3) != nil ? String(Int(const3)!) : "nil"
  18. let c4 = Int(const4) != nil ? String(Int(const4)!) : "nil"
  19. let c5 = Int(const5) != nil ? String(Int(const5)!) : "nil"
  20. print("\(c1) + \(c2) + \(c3) + \(c4) + \(c5) = \(sum)")
  21.  
  22. let plus = " + "
  23. let equal = " = "
  24. print(c1 + plus + c2 + plus + c3 + plus + c4 + plus + c5 + equal + String(sum))
  25.  
  26. //2 задание
  27. let kiss = "\u{1F48F}"
  28. let dragons = "\u{1F409}"
  29. let deer = "\u{1F98C}"
  30. let flamingo = "\u{1F9A9}"
  31. let beaty = "\u{1F3DE}"
  32. print(deer.count)
  33.  
  34. //3 задание
  35. var i = 0
  36. let alphabet = "qwertyuiopasdfghjklzxcvbnm"
  37. let word : Character = "f"
  38. var index = Int()
  39. for s in alphabet {
  40.     if s == word {
  41.         index = i
  42.     }
  43.     i += 1
  44. }
  45. print("Index of \(word) in QWERTY = \(index)")
Advertisement
Add Comment
Please, Sign In to add comment