位域的规律题

时间:2022-12-12 07:39:31 笔试题目 我要投稿
  • 相关推荐

位域的规律题

有无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;

  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;

  }

 

【位域的规律题】相关文章:

面试笔试题目规律题及答案08-01

台企招聘怪题:选如厕蹲位07-07

台企招聘怪题选如厕蹲位07-27

2016年中考化学实验题的答题规律06-21

Word域功能解析04-18

CAD怎么建立面域05-10

跳槽的规律08-05

面试问题—台企招聘怪题:选如厕蹲位07-31

Word 文档域功能详细介绍10-30

32位与64位系统的区别05-11