C ++中的整数的十进制,八进制和十六进制表示 [英] The decimal, octal and hexadecimal representation of an integer in C++

查看:115
本文介绍了C ++中的整数的十进制,八进制和十六进制表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用十进制,八进制或十六进制表示来表示整数的值?
(我只喜欢 iostream 用法)

How can I express the value of an integer using decimal, octal or hexadecimal representation? (I would prefer only iostream usage)

推荐答案

假设你只是想看到他们,为自己参考。虽然将它们存储在变量中是只是一个镜头。

Assuming you just want to see them, for your own reference. Though storing them in a variable is "just a shot away".

#include <iostream>
using namespace std;

int main () {
  int n;
  n=70;
  cout << hex << n << endl;
  cout << dec << n << endl;
  cout << oct << n << endl;
  return 0;
}

这篇关于C ++中的整数的十进制,八进制和十六进制表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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