반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <iostream> #include <algorithm> using namespace std; int a[5]; int main() { for (int i = 0; i < 5; i++) cin >> a[i]; while(1) { bool c = true; for (int i = 0; i < 5; i++) { if (a[i] != i + 1) c = false; } if (c) { break; } for (int i = 0; i < 4; i++) { if (a[i] > a[i + 1]) { swap(a[i + 1], a[i]); for (int j = 0; j < 5; j++) cout << a[j] << ' '; cout << '\n'; } } } } | cs |
'Algorithm' 카테고리의 다른 글
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 4766번:일반 화학 실험 답 (0) | 2017.04.07 |
---|---|
(C++) - 백준(BOJ) 5176번 : 대회 자리 (0) | 2017.04.06 |
(C++) - 백준(BOJ) 10996번 : 별찍기 - 21 답 (0) | 2017.04.03 |
(C++) - 백준(BOJ) 9243번 : 파일 완전 삭제 답 (0) | 2017.04.03 |
(C++) - 백준(BOJ)코딩 11023번 : 더하기 3 답 (0) | 2017.04.03 |