level 1
M_S_
楼主
#include "stdio.h"#
include "string.h"#include "math.h"long HEXtoDEC(char a[],int degree){ int i,degnum;long num; for(i=0,num=0;i
=0&°num<=15)) {printf("error!\n");num=0;break;} num+=degnum*pow(16,(degree-i-1));} return(num);}main(){ char a[20];printf("Please input a HEX number:");gets(a);strupr(a); if (a[0]!='-') printf("%s(HEX)=%ld(DEC)\n",a,HEXtoDEC(a,strlen(a))); else printf("%s(HEX)=-%ld(DEC)\n",a,HEXtoDEC(a+1,strlen(a+1))); getchar(); }本程序只能转换整数有什么问题欢迎指正,谢谢大家
2006年06月01日 13点06分
1
include "string.h"#include "math.h"long HEXtoDEC(char a[],int degree){ int i,degnum;long num; for(i=0,num=0;i
=0&°num<=15)) {printf("error!\n");num=0;break;} num+=degnum*pow(16,(degree-i-1));} return(num);}main(){ char a[20];printf("Please input a HEX number:");gets(a);strupr(a); if (a[0]!='-') printf("%s(HEX)=%ld(DEC)\n",a,HEXtoDEC(a,strlen(a))); else printf("%s(HEX)=-%ld(DEC)\n",a,HEXtoDEC(a+1,strlen(a+1))); getchar(); }本程序只能转换整数有什么问题欢迎指正,谢谢大家