Recent Posts
Notice
No Rules Rules
진법 변환 2 (feat. 백준, 11005번) 본문
728x90
반응형
진법 변환 2
https://www.acmicpc.net/problem/11005
11005번: 진법 변환 2
10진법 수 N이 주어진다. 이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를
www.acmicpc.net
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <stack>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
stack<char> arr;
register long long N, B, t;
cin >> N >> B;
while(N){
t = N % B;
N /= B;
if(0 <= t && t <= 9)
arr.push('0' + t);
else
arr.push('A' + t - 10);
}
while(!arr.empty())
cout << arr.top(), arr.pop();
return 0;
}
// *&)*@*
반응형
단순 연산 문제입니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
당신은 운명을 믿나요? (feat. 백준, 27930번) (0) | 2023.04.05 |
---|---|
작업 (feat. 백준, 2056번) (0) | 2023.04.04 |
진법 변환 (feat. 백준, 2745번) (0) | 2023.04.04 |
세탁소 사장 동혁 (feat. 백준, 2720번) (0) | 2023.03.31 |
녹색 옷 입은 애가 젤다지? (feat. 백준, 4485번) (0) | 2023.03.31 |
Comments