日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

正序 逆序写 java_C語言版和JAVA版 把一個字節正序(高位在前)轉為逆序(低位在前) 和 逆序轉為正序...

發布時間:2024/10/8 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 正序 逆序写 java_C語言版和JAVA版 把一個字節正序(高位在前)轉為逆序(低位在前) 和 逆序轉為正序... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、C語言版 把一個字節正序(高位在前)轉為逆序(低位在前) 和?逆序轉為正序

// xhrrj.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

//把一個字節 高位在前 轉為 低位在前

unsigned char Byte_Change(unsigned char ter)

{

unsigned char i=0;

unsigned char tem=0;

for(i=0;i<8;i++)

{

tem=tem<<1; //低位向左移

tem=((ter>>i)&0x01)|tem; //低位的值

}

return tem;

}

//把一個字節 低位在前 轉為 高位在前

unsigned char Byte_Change2(unsigned char ter)

{

unsigned char i=0;

unsigned char tem=0;

for(i=0;i<8;i++)

{

tem=tem>>1;

tem=((ter<

}

return tem;

}

void main(int argc, char* argv[])

{

unsigned char a=0;

a=Byte_Change(0x22);

printf("%02X\n",a);

a=Byte_Change2(0x44);

printf("%02X\n",a);

}

結果:

44

22

Press any key to continue

2.JAVA版

public class ByteChange {

static //把一個字節 高位在前 轉為 低位在前

int Byte_Change(int ter)

{

int i=0;

int tem=0;

for(i=0;i<8;i++)

{

tem=tem<<1; //低位向左移

tem=((ter>>i)&0x01)|tem; //低位的值

}

return tem;

}

//把一個字節 低位在前 轉為 高位在前

static int Byte_Change2(int ter)

{

int i=0;

int tem=0;

for(i=0;i<8;i++)

{

tem=tem>>1;

tem=((ter<

}

return tem;

}

public static void main(String[] args) {

// TODO Auto-generated method stub

int a=0;

a=Byte_Change(0x22);

System.out.printf("%02X\n",a);

a=Byte_Change2(0x44);

System.out.printf("%02X\n",a);

}

}

總結

以上是生活随笔為你收集整理的正序 逆序写 java_C語言版和JAVA版 把一個字節正序(高位在前)轉為逆序(低位在前) 和 逆序轉為正序...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。