Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.swift
- // kigyo
- //
- import Foundation
- let sor = 4
- let oszlop = 5
- var tomb = [[Int]]()
- for _ in 1...sor
- {
- var beszurando = [Int]()
- for _ in 1...oszlop
- {
- beszurando.append(Int.random(in: 0...9))
- }
- tomb.append(beszurando)
- }
- for i in 0...sor-1
- {
- print(tomb[i])
- }
- print()
- var fel_le = false
- // fel: true
- // le: false
- var melyikoszlop = 0
- var kimenet = [Int]()
- while melyikoszlop < oszlop
- {
- if !fel_le
- {
- for i in 0...sor-1
- {
- kimenet.append(tomb[i][melyikoszlop])
- }
- melyikoszlop += 1
- fel_le = true
- continue
- }
- else if fel_le
- {
- for i in 0...sor-1
- {
- kimenet.append(tomb[sor-1-i][melyikoszlop])
- }
- melyikoszlop += 1
- fel_le = false
- continue
- }
- }
- print (kimenet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement