# include & ltconio.h & gt
# include & ltstring.h & gt
#定義編號1000
char str[N];
int a[N],b[N];
int main(void)
{
void zsh();
long YCL();
int i,n;
做{
Printf("請輸入壹個十六進制數:\ n ");
scanf("%s ",str);
for(i=0,n = 0;str[i]!='\0';i++)
if(str[I]& lt;0 ' | |(str[I]& gt;9 ' & amp& ampstr[I]& lt;A')||(str[i]>f & amp;& ampstr[I]& lt;a')||str[i]>f’)
{
n = 1;
Printf("輸入不符合要求\ n ");
打破;
}
} while(n);
zsh();
Printf("十進制轉換後的結果為%ld\n ",YCL());
getch();
}
void zsh()
{
int i,j;
j = strlen(str)-1;
b[j]= 1;
for(I = j;我& gt0;我-)
b[I-1]= b[I]* 16;
}
長ycl()
{
long x,I,j;
j = strlen(str)-1;
for(x=0,I = j;我& gt=0;我-)
{
if(str[i]>= ' a ' & amp& ampstr[I]& lt;='z ')
a[I]= str[I]-' a '+10;
else if(str[I]& gt;= ' A ' & amp& ampstr[I]& lt;='Z ')
A[I]= str[I]-' A '+10;
其他
a[I]= str[I]-' 0 ';
x = x+a[I]* b[I];
}
返回x;
}