- 相關(guān)推薦
位域的規(guī)律題
有無(wú)unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值來(lái)試驗(yàn)就可發(fā)現(xiàn)位域的規(guī)律,
位域的規(guī)律題
。#include <iostream>
#include <windows.h>
using namespace std;
void main()
{
struct test
{
//在這里測(cè)試就可以發(fā)現(xiàn)其規(guī)律,有無(wú)unsigned、a:1 a:2 a:4 a:8 a:16 a:32 以及用char的各值來(lái)試驗(yàn)就可發(fā)現(xiàn)位域的規(guī)律
unsigned int a:8;
};
test t1;
t1.a = 0;
cout<<"十進(jìn)制 -> 0: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 0: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 1;
cout<<"十進(jìn)制 -> 1: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 1: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 2;
cout<<"十進(jìn)制 -> 2: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 2: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 3;
cout<<"十進(jìn)制 -> 3: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 3: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 126;
cout<<"十進(jìn)制 -> 126: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 126: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 127;
cout<<"十進(jìn)制 -> 127: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 127: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 128;
cout<<"十進(jìn)制 -> 128: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 128: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 129;
cout<<"十進(jìn)制 -> 129: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 129: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 253;
cout<<"十進(jìn)制 -> 253: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 253: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 254;
cout<<"十進(jìn)制 -> 254: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 254: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 255;
cout<<"十進(jìn)制 -> 255: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 255: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 256;
cout<<"十進(jìn)制 -> 256: "<<dec<<t1.a<<endl;
cout<<"十六進(jìn)制-> 256: "<<hex<<t1.a<<endl;
cout<<endl;
t1.a = 257;
【位域的規(guī)律題】相關(guān)文章:
職場(chǎng)生存規(guī)律08-10
4條學(xué)習(xí)規(guī)律09-26
小學(xué)數(shù)學(xué)說(shuō)課稿《點(diǎn)陣中的規(guī)律》06-15
《找規(guī)律》教學(xué)反思(通用14篇)10-12
中班科學(xué)活動(dòng)《找規(guī)律》說(shuō)課稿08-31
位辦理社保介紹信08-13