首页 > 试题广场 >

进制转换

[编程题]进制转换
  • 热度指数:18898 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

写出一个程序,接受一个十六进制的数值字符串,输出该数值的十进制字符串(注意可能存在的一个测试用例里的多组数据)。


输入描述:

输入一个十六进制的数值字符串。



输出描述:

输出该数值的十进制字符串。

示例1

输入

0xA

输出

10
头像 鱼儿恋上水
发表于 2020-03-24 23:49:50
%x:以16进制数的方式,从键盘输入一个整数存到变量中%d:以10进制数的方式 #include <stdio.h> int main() { int num = 0; while (~scanf ("%x", &num)) printf("%d 展开全文
头像 牛客652687585号
发表于 2022-02-24 20:04:47
#include<iostream> #include<cstdio> #include<string> using namespace std; int main(){     string 展开全文
头像 在做毕设的鲸鱼很刻苦
发表于 2023-03-04 00:07:46
#include <string> #include <iostream> #include <map> #include <cmath> using namespace std; int main() { string str; m 展开全文
头像 ysong想养只修狗
发表于 2023-05-13 19:39:57
#include <iostream> using namespace std; int CharToInt(char c){ if(c >= '0' && c <= '9') return c - '0'; else return c - 'A' + 展开全文
头像 Huster水仙
发表于 2023-01-14 17:28:28
#include<iostream> #include<string> using namespace std; int main(){ string s; while(cin>>s){ long long ans=0; 展开全文
头像 苇岸弦歌
发表于 2023-02-15 17:25:41
n进制到10进制可以有两种转换思路:一种是乘n加余,一种是a*(n^k)累加 #include <iostream> #include "stack" #include "cmath" using namespace std; int charToInt(char c) { if 展开全文
头像 薇薇啵啵
发表于 2020-04-08 15:17:42
/* * M进制转换成十进制数 */ #include <iostream> #include <cstdio> #include <vector> using namespace std; int CharToInt(char target){ 展开全文
头像 窝在小角落里刷题
发表于 2023-02-07 17:27:17
#include <iostream> #include <cstdio> #include <string> #include <algorithm> using namespace std; /** * char转int * @param 展开全文
头像 窝在小角落里刷题
发表于 2023-02-07 17:28:49
#include <iostream> #include <cstdio> #include <string> #include <algorithm> using namespace std; /** * char转int * @param 展开全文
头像 着力登峰
发表于 2023-08-11 10:20:21
#include <iostream> #include <string> using namespace std; // 将十六进制字符转换为对应的整数 int CharToInt(char c) { if (c >= '0' && c &l 展开全文

问题信息

难度:
106条回答 13466浏览

热门推荐

通过挑战的用户

查看代码