- 相关推荐
位域的规律题
有无unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值来试验就可发现位域的规律,
位域的规律题
。#include <iostream>
#include <windows.h>
using namespace std;
void main()
{
struct test
{
//在这里测试就可以发现其规律,有无unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值来试验就可发现位域的规律
unsigned int a:8;
};
test t1;
t1.a = 0;
cout<<"十进制 -> 0: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 0: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 1;
cout<<"十进制 -> 1: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 1: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 2;
cout<<"十进制 -> 2: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 2: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 3;
cout<<"十进制 -> 3: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 3: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 126;
cout<<"十进制 -> 126: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 126: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 127;
cout<<"十进制 -> 127: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 127: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 128;
cout<<"十进制 -> 128: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 128: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 129;
cout<<"十进制 -> 129: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 129: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 253;
cout<<"十进制 -> 253: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 253: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 254;
cout<<"十进制 -> 254: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 254: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 255;
cout<<"十进制 -> 255: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 255: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 256;
cout<<"十进制 -> 256: "<<dec<<t1.a<<endl;
cout<<"十六进制-> 256: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 257;
【位域的规律题】相关文章:
职场生存规律08-10
4条学习规律09-26
职场黄金规律16条08-05
小学数学说课稿《点阵中的规律》06-15
《找规律》教学反思(通用14篇)10-12
中班科学活动《找规律》说课稿08-31
位办理社保介绍信08-13
考研必知的三个高效记忆规律05-24
考研英语阅读理解7大命题规律09-20
小班数学《按简单规律排序》活动反思09-24