📄 main.cpp
字号:
#include <iostream>
#include <ostream>
#include <fstream>
using namespace std;
const int JINZHI =16;
void Trans(char *con)
{
char content[17]="0123456789ABCDEF";
int i;
int pos;
int temp;
char after[500];
int is;
int j;
int k;
char res[500];
int Positi=0;
while (1)
{
pos=0;
temp=0;
while (con[pos])
{
while (temp<JINZHI && con[pos])
{
temp=temp*10+ con[pos]-'0';
after[pos]='0';
pos++;
}
pos--;
if (temp% JINZHI >=10 )
{
con[pos-1]='1';
con[pos]=temp%JINZHI -10 +'0';
i=pos-1;
}
else
{
con[pos]=temp%JINZHI +'0';
i=pos;
}
after[pos]=temp/JINZHI+'0';
temp%=JINZHI;
pos++;
}
after[pos]=0;
//
//con----YuShu
//
temp=0;
for (j=i;con[j];j++)
temp=temp*10+ con[j]-'0';
//
//save the result
//
res[Positi++]=content[temp];
//
//prepare the next loop
//
is=0;
for (j=0;after[j];j++)
{
if(after[j]!='0')
break;
else
is=j;
}
for (j=is,k=0; after[j]; j++,k++)
con[k]=after[j];
con[k]=0;
if (strcmp( con,"0")==0 )
break;
}
//
//Last Adjust(delete the last 0s)
//
for (i=Positi-1;i>=0;i--)
{
if (res[i] != '0')
{
is=i;
break;
}
}
for (i=0,j=is;j>=0;j--)
con[i++]=res[j];
con[i++]=0;
}
#define LENGTH 200
int main()
{
char a[LENGTH];
ofstream os;
ifstream is;
is.open("Data.txt");
if( is.fail())
{
cout<<"File Miss"<<endl;
getchar();
return 0;
}
os.open("Result.txt");
if( os.fail())
{
cout<<"Create Error!"<<endl;
getchar();
return 0;
}
while(!is.eof())
{
is.getline(a,LENGTH);
Trans(a);
os<<a<<endl;
}
is.close();
os.close();
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -