• 十进制


     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 using namespace std;
     5 int main(int argc, char** argv) {
     6     
     7         //声明变量,并初始化
     8     int a=010,b=10,c=0X10; 
     9 
    10     //以十进制形式显示数据
    11     cout<<"DEC:";
    12     cout<<" a="<<a;
    13     cout<<" b="<<b;
    14     cout<<" c="<<c<<endl; 
    15     
    16     //以八进制形式显示数据
    17     cout<<"OCT:";
    18     cout<<oct;             //指定八进制输出
    19     cout<<" a="<<a;
    20     cout<<" b="<<b;
    21     cout<<" c="<<c<<endl;  
    22     
    23     //以十六进制形式显示数据
    24     cout<<"HEX:";
    25     cout<<hex;            //指定十六进制输出
    26     cout<<" a="<<a;
    27     cout<<" b="<<b;
    28     cout<<" c="<<c<<endl;  
    29 
    30     //八、十和十六进制数混合运算并输出
    31     cout<<"a+b+c=";
    32     cout<<dec;            //恢复十进制输出
    33     cout<<a+b+c<<endl;
    34 
    35     //测试八、十和十六进制输入
    36     cout<<"DEC:a="; cin>>a;
    37     cout<<"OCT:b="; cin>>b;
    38     cout<<"HEX:a="; cin>>c;
    39     cout<<"DEC:"<<dec<<endl;            //指定十进制输出
    40     cout<<"a="<<a<<endl;
    41     cout<<"b="<<b<<endl;
    42     cout<<"c="<<c<<endl;
    43     return 0;
    44 }
  • 相关阅读:
    查看串口设备
    JavaScript 闭包
    JS中decodeURI()与decodeURIComponent()
    js 获取浏览器高度和宽度值(多浏览器)
    几种常用网页返回顶部代码
    CSS3 Transition
    jquery操作css
    如何改变hr的颜色
    标签导航——display属性
    思考性能问题
  • 原文地址:https://www.cnblogs.com/borter/p/9405647.html
Copyright © 2020-2023  润新知