1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h> #include <queue> using namespace std; int main() { int n; scanf("%d", &n); queue<int> q; for (int i = 1; i <= n; i++) q.push(i); while (q.size() > 0) { printf("%d ", q.front()); q.pop(); if (q.size() > 0) { q.push(q.front()); q.pop(); } } } | cs |
'알고리즘 > 시뮬레이션' 카테고리의 다른 글
1592 영식이와 친구들 (0) | 2020.01.15 |
---|---|
2979 트럭 주차 (0) | 2020.01.15 |
2164 카드2 (0) | 2020.01.15 |
1547 공 (0) | 2020.01.15 |
2455 지능형 기차 (0) | 2020.01.14 |