Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157632
  • 博文数量: 76
  • 博客积分: 1513
  • 博客等级: 上尉
  • 技术积分: 755
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-25 15:15
文章分类

全部博文(76)

文章存档

2012年(2)

2011年(74)

我的朋友

分类: C/C++

2011-11-25 20:47:29

  1. #include <iostream>

  2. #include <fstream>

  3. using namespace std;

  4.  

  5. int main()

  6. {

  7.  

  8. unsigned char * array = new unsigned char[8];

  9.  

  10.  

  11. array[0]=0x32;

  12. cout << hex <<(int)array[0]<<" ";

  13.  

  14. for(int i=1;i<8;i++)

  15. {

  16.         array[i]=array[i-1]+2;

  17.         cout <<hex<<(int)array[i]<< " ";

  18. }

  19. cout<<endl;

  20.  

  21.  

  22. unsigned long long result;

  23. unsigned long long result1;

  24. unsigned long long result2;

  25.  

  26.          cout << "array[0] >> 56 = " << (array[0] << 56) <<endl;

  27.  

  28.         result1 = (array[0] <<24) ^ (array[1] <<16)^ (array[2] << 8) ^ array[3];

  29.         result2 = (array[4] <<24) ^ (array[5] <<16)^ (array[6] << 8) ^ array[7] ;

  30.         cout << result1 << endl;

  31.         cout << result2 << endl;

  32.         result = (result1<<32)^result2;

  33.         cout << dec <<(unsigned long long)result;


  34.         return 0;
  35. }

output:

32 34 36 38 3a 3c 3e 40 

array[0] >> 56 = 32000000

32343638

3a3c3e40

3617576015808446016


阅读(697) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~