#include <iostream>
using namespace std;
void reserve(char a[])
{
int count = 0, temp = 0,max = 0;
char *p = a;
//指向末尾
while(*p++!='\0')
{
count++;
}
int len = max = (count+1)/4-1;
int *b= new int[len+1];
count--;
while(count>2)
{
temp = a[count--]-48;
temp += 2*(a[count--]-48);
temp += 4*(a[count--]-48);
temp += 8*(a[count--]-48);
b[len--] = temp;
}
if(count==2)
b[0] = a[2]+2*a[1]+4*a[0]-7*48;
if(count==1)
b[0] = a[1]+2*a[0]-3*48;
if(count==0)
b[0] = a[0]-48;
for (int i=0; i<=max; i++)
{
cout<<hex<<b[i];
}
cout<<endl;
delete []b;
}
void main()
{
char a[]="111111111111111111111111111";
reserve(a);
}
二进制转换成字符串
最新推荐文章于 2023-08-15 14:27:18 发布