mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
B2143 进制转换
R52965724
This commit is contained in:
parent
34b426f6b0
commit
a566d63c0b
29
Luogu/problem/B2143/B2143.cpp
Normal file
29
Luogu/problem/B2143/B2143.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
char itoc(int x) {
|
||||
char r;
|
||||
switch (x) {
|
||||
case 10: r = 'A'; break;
|
||||
case 11: r = 'B'; break;
|
||||
case 12: r = 'C'; break;
|
||||
case 13: r = 'D'; break;
|
||||
case 14: r = 'E'; break;
|
||||
case 15: r = 'F'; break;
|
||||
default: r = x + '0'; break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int main() {
|
||||
string s, r;
|
||||
int x, m;
|
||||
cin >> x >> m;
|
||||
while (x) {
|
||||
r = itoc(x % m) + r;
|
||||
x /= m;
|
||||
}
|
||||
cout << r << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user