2진수 8진수
백준 / 수학 / 1373번 / 2진수 8진수 / C++
문제 2진수가 주어졌을 때, 8진수로 변환하는 프로그램을 작성하시오. 입력 첫째 줄에 2진수가 주어진다. 주어지는 수의 길이는 1,000,000을 넘지 않는다. 출력 첫째 줄에 주어진 수를 8진수로 변환하여 출력한다. 예제 입력 1 11001100 예제 출력 1 314 #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string result = ""; string n; cin >> n; if(n.length() % 3 == 1) n = "00" + n; else if(n.length() % 3 == 2) n = "0" + n; int len = n.length(); for(int i=2; i