码迷,mamicode.com
首页 > 编程语言 > 详细

算法 进制转换

时间:2019-10-08 16:00:18      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:ng2   art   out   cout   输出   name   details   十六进制   using   

十六进制转十进制

八进制转十进制

二进制转十进制之类的需要自己手动计算取余

 

C++

#include <iostream>
using namespace std;

int main()
{
int a;
while(cin>>hex>>a){// while(cin>>oct>>a)八进制转换
cout<<a<<endl;
}
}

拆开输出

int a=10;

cout<<hex;

cout<<a;    // 0xA

cout<<oct;

cout<<a;    //8

 

 

参考:https://blog.csdn.net/xuyongbeijing2008/article/details/7891148

算法 进制转换

标签:ng2   art   out   cout   输出   name   details   十六进制   using   

原文地址:https://www.cnblogs.com/liuruoqian/p/11635741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!