首页 > 试题广场 >

数制转换

[编程题]数制转换
  • 热度指数:12796 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    求任意两个不同进制非负整数的转换(2进制~16进制),所给整数在long所能表达的范围之内。     不同进制的表示符号为(0,1,...,9,a,b,...,f)或者(0,1,...,9,A,B,...,F)。

输入描述:
    输入只有一行,包含三个整数a,n,b。a表示其后的n 是a进制整数,b表示欲将a进制整数n转换成b进制整数。a,b是十进制整数,2 =< a,b <= 16。
    数据可能存在包含前导零的情况。


输出描述:
    可能有多组测试数据,对于每组数据,输出包含一行,该行有一个整数为转换后的b进制数。输出时字母符号全部用大写表示,即(0,1,...,9,A,B,...,F)。
示例1

输入

15 Aab3 7

输出

210306
头像 健康快乐最重要
发表于 2020-03-04 12:03:01
给一个进制转换的板子(只要是2-36进制的转换都可以,不喜勿喷):x:2-36的任何进制(int),36是因为10个数字+26个英文字母,所以最多有36进制。y:2-36的任何进制(int)a:2-36的任何进制表示的数(string)string divide(int x,string a,int 展开全文
头像 Huster水仙
发表于 2023-01-14 18:51:18
用栈即可 #include<iostream> #include<stack> #include<string> using namespace std; int main(){ string s; stack<char>ans; 展开全文
头像 pppoint
发表于 2024-02-29 20:45:30
决定了,以后遇上进制转换就这么写! #include<cstdio> #include<string> #include<vector> using namespace std; int charToint(char num) { if (num > 展开全文
头像 多多zz
发表于 2020-03-30 12:04:37
蒟蒻的我... #include<bits/stdc++.h> using namespace std; int charToNumber(char c) { switch(c) { case '0':return 0; case '1' 展开全文
头像 拒绝内卷plus
发表于 2024-03-26 01:14:13
#include <stdio.h> #include <string.h> int main() { int a, b; char n[50]; while (scanf("%d%s%d", &a,n ,&b) ! 展开全文
头像 土尔逊Torson
发表于 2023-05-06 23:59:32
//土尔逊Torson 编写于2023/5/06 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <string> #include <vector 展开全文
头像 宁静的冬日
发表于 2022-03-09 08:46:08
#include<iostream> using namespace std; #include<algorithm> #include<cstring> #include<iomanip> #include<string> int a[1 展开全文
头像 mean._
发表于 2023-03-02 14:03:35
#include <stdio.h> int main() { int a, b; char n[100]; char charac[16]={"0123456789ABCDEF"}; while (scanf("%d %s %d", &a,n, &b) 展开全文
头像 MountainsHao
发表于 2024-03-26 15:24:19
#include <stdio.h> #include <string.h> int main() { int a, b; char n[105]; while (scanf("%d %s %d", &a, n, & 展开全文
头像 小花Student
发表于 2024-03-19 20:32:52
#include<iostream> #include<cmath> #include<algorithm> int main() { char sys[16]={'0','1','2','3','4','5','6','7','8','9','A','B 展开全文

问题信息

难度:
115条回答 9799浏览

热门推荐

通过挑战的用户

查看代码