Skip to content

Commit fd89ca7

Browse files
committed
Add 카드2
1 parent 353a927 commit fd89ca7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: .DS_Store

0 Bytes
Binary file not shown.

Diff for: 스택, 큐/2164_카드2.swift

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let N = Int(readLine() ?? "")!
2+
3+
4+
if 1 <= N && N <= 500000 {
5+
var cards: [Int] = []
6+
var head = 0
7+
8+
for num in 1...N {
9+
cards.append(num)
10+
}
11+
12+
while head != cards.count-1 {
13+
head += 1
14+
cards.append(cards[head])
15+
head += 1
16+
}
17+
18+
print(cards[head])
19+
}

0 commit comments

Comments
 (0)