Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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 29 30 31
Archives
Today
Total
관리 메뉴

게임 개발 메모장

41. K진수 출력 본문

문제 해결력 훈련

41. K진수 출력

Dev_Moses 2024. 1. 18. 22:08

 

 

#include <iostream>
#include <vector>

using namespace std;

int top = -1;
int stack[1001];

void Push(int x)
{
	stack[++top] = x;
}

int Pop()
{
	return stack[top--];
}

int main()
{
	int n,m;
	cin >> n >> m;

	char str[20] = "0123456789ABCDEF";

	while (n > 0)
	{
		Push(n % m);
		n /= m;
	}

	while (top != -1)
	{
		cout << str[Pop()];
	}
}

'문제 해결력 훈련' 카테고리의 다른 글

43. 기차운행(stack 응용)  (0) 2024.01.18
42. 올바른 괄호(stack)  (0) 2024.01.18
40. 이진트리 깊이우선탐색(DFS  (0) 2024.01.18
39. 재귀함수 이진수 출력  (0) 2024.01.18
38. 재귀 함수 분석  (0) 2024.01.18