进制转换Word格式文档下载.docx
- 文档编号:22831964
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:13
- 大小:15.77KB
进制转换Word格式文档下载.docx
《进制转换Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《进制转换Word格式文档下载.docx(13页珍藏版)》请在冰豆网上搜索。
if(_two==0)
returntwo;
}
else
if(yu==0)
returnfanhui=_TwotoTen(_two)*2;
returnfanhui=_TwotoTen(_two)*2+yu;
privateint_TentoTwo(intten)
intjieguo;
intyu=ten%2;
int_ten=ten/2;
if(_ten==0)
returnten;
returnjieguo=_TentoTwo(_ten)*10;
returnjieguo=_TentoTwo(_ten)*10+yu;
privateint_TentoEight(intten)
intyu=ten%8;
intlest=ten/8;
if(lest==0)
returnjieguo=_TentoEight(lest)*10;
returnjieguo=_TentoEight(lest)*10+yu;
privateint_EighttoTen(inttwo)
intyu=two%10;
inteight=two/10;
if(eight==0)
returnfanhui=_EighttoTen(eight)*8;
returnfanhui=_EighttoTen(eight)*8+yu;
publicstringTwotoEight(stringtwo)
inttwo_length=two.Length%3;
if(two_length!
=0)
for(inta=two_length;
a<
3;
a++)
two="
0"
+two;
//补零,让元素的个数为3的倍数
string[]fengzu=newstring[two.Length/3];
//生成一个的string[]数组,用来给_string_two分组
for(inta=0;
fengzu.Length;
fengzu[a]=two.Substring(a*3,3);
//每3个元素放到一组,当做fengzu[]的新元素
fengzu[a]=Convert.ToString(_TwotoTen(Convert.ToInt32(fengzu[a])));
stringEight="
"
;
foreach(stringainfengzu)
Eight+=a;
returnEight;
publicstringEighttoTwo(stringeight)
string[]str_eight=newstring[eight.Length];
int[]chaifen=newint[eight.Length];
//8进制每个元素都转换成10进制整数放到该数组
str_eight.Length;
a++)//string类实际上是一个char[]数组。
//把这个数组的元素转移到一个string[]数组里
str_eight[a]=eight[a].ToString();
stringtt="
//记载每个8进制元素转换成3位2进制数后组装后的结果
foreach(stringainstr_eight)//组装2进制
switch(_TentoTwo(Convert.ToInt32(a)).ToString().Length)
case2:
tt+="
+_TentoTwo(Convert.ToInt32(a)).ToString();
break;
case1:
00"
default:
tt+=_TentoTwo(Convert.ToInt32(a)).ToString();
returntt;
publicstringTwotoSixteen(stringtwo)
string_string_two=two;
int_string_two_length=_string_two.Length%4;
if(_string_two_length!
for(inta=_string_two_length;
4;
_string_two="
+_string_two;
//补零,让元素的个数为4的倍数
string[]fengzu=newstring[_string_two.Length/4];
fengzu[a]=_string_two.Substring(a*4,4);
//每4个元素放到一组,当做fengzu[]的新元素
switch(fengzu[a])
case"
10"
:
fengzu[a]="
a"
11"
b"
12"
c"
13"
d"
14"
e"
15"
f"
fengzu[a]=fengzu[a];
stringsixteen="
sixteen+=a;
returnsixteen;
publicstringSixteentoTwo(stringsixteen)
string[]str_sixteen=newstring[sixteen.Length];
int[]chaifen=newint[sixteen.Length];
//16进制每个元素都转换成10进制整数放到该数组
intchaifeng_x=0;
//数组chaifeng的索引
//记载每个16进制元素转换成4位2进制数后组装后的结果
str_sixteen.Length;
str_sixteen[a]=sixteen[a].ToString();
foreach(stringxinstr_sixteen)
switch(x)
chaifen[chaifeng_x]=10;
chaifen[chaifeng_x]=11;
chaifen[chaifeng_x]=12;
chaifen[chaifeng_x]=13;
chaifen[chaifeng_x]=14;
chaifen[chaifeng_x]=15;
chaifen[chaifeng_x]=Convert.ToInt32(x);
chaifeng_x++;
foreach(intainchaifen)//组装2进制
switch(_TentoTwo(a).ToString().Length)
case3:
+_TentoTwo(a).ToString();
000"
tt+=_TentoTwo(a).ToString();
publicstringTentoEight(stringten)
returnConvert.ToString(_TentoEight(Convert.ToInt32(ten)));
publicstringEighttoTen(stringeight)
returnConvert.ToString(_EighttoTen(Convert.ToInt32(eight)));
publicstringTwotoTen(stringtwo)
returnEighttoTen(TwotoEight(two));
publicstringEighttoSixteen(stringeight)
returnTwotoSixteen(EighttoTwo(eight));
publicstringTentoTwo(stringten)
returnEighttoTwo(TentoEight(ten));
publicstringTentoSixteen(stringten)
returnTwotoSixteen(TentoTwo(ten));
publicstringSixteentoEight(stringsixteen)
returnTwotoEight(SixteentoTwo(sixteen));
publicstringSixteentoTen(stringsixteen)
returnTwotoTen(SixteentoTwo(sixteen));
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 转换