Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
48627 郑九熊 十进制转R进制 C++ Accepted 0 MS 276 KB 604 2023-06-10 15:47:46

Tests(10/10):


Code:

#include <iostream> #include <cmath> #include <string> //#include <bits/stdc++.h> using namespace std; int main() { //freopen("1538.in", "r", stdin); //freopen("1538.out", "w", stdout); int n; int jz; cin >> n >> jz; int a[33] = {}; int cnt = 0; string b = "ABCDEF"; //整数部分转换以及输出 int t = n; if (t == 0) { cout << 0; } else { while (t != 0) { a[cnt] = t % jz; t /= jz; cnt++; } for (int i = cnt - 1; i >= 0; i--) { if (a[i] < 10) { cout << a[i]; } else { cout << b[a[i] - 10]; } } } return 0; }