teacher_code_c/B3849 [GESP样题 三级] 进制转换.cpp

38 lines
835 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//#include <iostream>
//using namespace std;
//
//// 函数:将单个数字转换为对应字符
//void zhuanhuan(int n) {
// if (n >= 10) {
// // 对于 10 及以上的值转换为对应的字母A = 10B = 11等等
// char b = n + 55;
// cout << b;
// }
// else {
// // 对于小于 10 的值,直接输出数字
// cout << n;
// }
//}
//
//// 函数:将数字 n 转换为 b 进制
//void jinzhi(int n, int b) {
// if (n / b == 0) {
// // 基本情况:当 n 小于 b 时,转换并输出余数
// zhuanhuan(n % b);
// return;
// }
// // 递归情况:先处理高位数字
// jinzhi(n / b, b);
// // 转换并输出当前位数字
// zhuanhuan(n % b);
//}
//
//int main() {
// int n, b;
// // 从用户输入读取整数和进制
// cin >> n >> b;
// // 将数字转换为指定进制并输出结果
// jinzhi(n, b);
// return 0;
//}