근본없는 코딩
[C++] 백준11005 진법변환2 본문

#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int b, n;
string sum ="";
cin >> n >> b;
while (n!=0) {
int tmp = n % b;
n = n / b;
if (tmp < 10) sum += (tmp + '0');
else sum += (tmp + 'A' - 10);
}
for (int i =0; i < sum.length(); i++) {
cout << sum[sum.length() - i - 1];
}
cout << '\n';
return 0;
}'✔ Online Judge' 카테고리의 다른 글
| [C++] 백준3003 킹,퀸,룩,비숍,나이트, (0) | 2023.06.29 |
|---|---|
| [C++] 백준25083 새싹 (0) | 2023.06.29 |
| [C++] 백준2745 진법변환 (0) | 2023.06.26 |
| [C++] 백준2042 구간 합 구하기 (0) | 2023.06.25 |
| [C++] 백준11718 그대로 출력하기 (0) | 2023.06.25 |