将二进制数转换为相应的八进制数... [英] Convert binary number into its corresponding octal number...

查看:86
本文介绍了将二进制数转换为相应的八进制数...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将二进制数转换为c ++中对应的八进制数。请帮我...执行程序。

How to Convert binary number into its corresponding Octal Number in c++.PLease help me...to do the program.

推荐答案

转换二进制文件一个数字的表示(就像一个字符串,例如00101100)到它的八进制表示非常简单,只是从右边开始,转换 3 字符组,例如

Converting the binary representation of a number (that is a string like, for instance "00101100") to its octal representation is pretty simple, just convert group of 3 characters at time, starting from the right, e.g.
00101100 -> 00 101 100 -> 054





另一方面,如果你只需要一个数字的八进制表示,它甚至更简单,例如



On the other hand, if you just need the octal representation of a number than, it is even simpler, e.g.

int x = 44;
cout << oct << x << endl;


很容易在google上找到建议,例如这个建议

http://www.sanfoundry.com/c-program-convert-binary-octal/ [ ^ ]
Very easy to find suggestions on google, such as this one
http://www.sanfoundry.com/c-program-convert-binary-octal/[^]


这篇关于将二进制数转换为相应的八进制数...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆