VioletaBabel
1212번: 8진수 2진수 본문
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 | #include<iostream> #include<string> using namespace std; int main() { string oct; cin >> oct; if (oct == "0") { cout << oct; return 0; } bool isFirst = true; for (int i = 0, len = oct.length(); i < len; ++i) { int t = (int)oct[i] - '0'; for (int j = 4; j; t %= j, j /= 2) { if (isFirst) if (t / j == 0) continue; cout << t / j; if (isFirst) isFirst = false; } } } | cs |
'백준 > 백준-C++' 카테고리의 다른 글
1350번: 진짜 공간 (0) | 2018.12.31 |
---|---|
15953번: 상금 헌터 (0) | 2018.12.10 |
1145번: 적어도 대부분의 배수 (0) | 2018.12.06 |
1021번: 회전하는 큐 (0) | 2018.12.04 |
1003번: 피보나치 함수 (0) | 2018.06.26 |