Advertisement
vadim_sharaf

Untitled

Mar 8th, 2023
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.14 KB | None | 0 0
  1. //1 задание
  2. var journal =  ["Alex B" : 4, "Johnny C" : 3, "Gavrila H" : 5, "Tosya M" : 3, "Tur" : 4]
  3. journal["Johnny C"] = 5
  4. journal["Tosya M"] = 4
  5. journal["Fred G"] = 3
  6. journal["Kira T"] = 5
  7. journal["Alex B"] = nil
  8. journal["Tur"] = nil
  9. var total = Int()
  10. var avarage = Double()
  11. for value in journal.values {
  12.     total += value
  13. }
  14. avarage = Double(total) / Double(journal.count)
  15. print("The total score of group: \(total), the avarage score: \(avarage)\n")
  16.  
  17. //2 задание
  18. let moths = ["Jan" : 31, "Feb" : 28, "Mar" : 31, "Apr" : 30, "May" : 31, "Jun" : 30, "Jul" : 31, "Aug" : 31, "Sep" : 30, "Oct" : 31, "Nov" : 31, "Dec" : 31]
  19. for (key, value) in moths {
  20.     print("Moth : \(key) - days : \(value)")
  21. }
  22. print("\n")
  23. for moth in moths.keys {
  24.     print("Moth : \(moth) - days : \(moths[moth]!)")
  25. }
  26. var chess = [String : Bool]()
  27. var i = 1
  28. for letter in "ABCDEFGH" {
  29.     for num in "12345678" {
  30.         let num = String(num)
  31.         let letter = String(letter)
  32.         if (i + Int(num)!) % 2 == 0 {
  33.             chess[letter + num] = false
  34.         } else {
  35.             chess[letter + num] = true
  36.         }
  37.     }
  38. }
  39. print(chess)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement