1 条题解
-
0
普通的进制转换模板题
#include <iostream> #include <algorithm> using namespace std; string d2r(int n, int r){ string s = "";while (n > 0){ int t = n % r;n /= r; if (t < 10)s = char(t + '0') + s; else s = char(t - 10 + 'A') + s; }return s; }int main() {int n, m; while (cin >> n >> m){ if (n == 0)cout << 0; else{if (n != abs(n)) { cout << "-"; n = abs(n); }cout << d2r(n, m); }cout << endl; } }
- 1
信息
- ID
- 223
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 5
- 已通过
- 2
- 上传者