- 相關(guān)推薦
位域的規(guī)律題
有無unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值來試驗就可發(fā)現(xiàn)位域的規(guī)律。
#include <iostream>
#include <windows.h>
using namespace std;
void main()
{
struct test
{
//在這里測試就可以發(fā)現(xiàn)其規(guī)律,有無unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值來試驗就可發(fā)現(xiàn)位域的規(guī)律
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;
cout<<"十進制 -> 257: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 257: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 258;
cout<<"十進制 -> 258: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 258: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 259;
cout<<"十進制 -> 259: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 259: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 260;
cout<<"十進制 -> 260: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 260: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 261;
cout<<"十進制 -> 261: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 261: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 262;
cout<<"十進制 -> 262: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 262: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 263;
cout<<"十進制 -> 263: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 263: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 264;
cout<<"十進制 -> 264: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 264: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 65533;
cout<<"十進制 -> 65533: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 65533: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 65534;
cout<<"十進制 -> 65534: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 65534: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 65535;
cout<<"十進制 -> 65535: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 65535: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 65536;
cout<<"十進制 -> 65536: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 65536: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 65537;
cout<<"十進制 -> 65537: "<<dec<<t1.a<<endl;
cout<<"十六進制-> 65537: "<<hex<<t1.a<<endl;
cout<<endl;
}
【位域的規(guī)律題】相關(guān)文章:
面試筆試題目規(guī)律題及答案08-01
臺企招聘怪題:選如廁蹲位07-07
臺企招聘怪題選如廁蹲位07-27
Word域功能解析04-18
CAD怎么建立面域05-10
跳槽的規(guī)律08-05
面試問題—臺企招聘怪題:選如廁蹲位07-31
Word 文檔域功能詳細介紹10-30