BOJ
11762 A Towering Problem
공부정리
2017. 8. 31. 00:46
3중 for문
<코드>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> #include <queue> using namespace std; int a[6], b, c; int main() { for (int i = 0; i < 6; i++) scanf("%d", &a[i]); scanf("%d%d", &b, &c); for (int i = 0; i < 6; i++) for (int j = i + 1; j < 6; j++) for (int k = j + 1; k < 6; k++) { if (a[i] + a[j] + a[k] == b) { priority_queue<int> q; q.push(a[i]); q.push(a[j]); q.push(a[k]); while (q.size()) printf("%d ", q.top()), q.pop(); for (int l = 0; l < 6; l++) if (l^i && l^j && l^k) q.push(a[l]); while (q.size()) printf("%d ", q.top()), q.pop(); return 0; } } return 0; } | cs |