C语言实现任意进制转换.doc
includestdio.h#includemath.h#includestring.hvoid dtox(double num,int jz)char xnum100;int dnum=(int) num;int i=0,j=0,e = 0;while(dnum=jz)xnumj+=dnum%jz+48;dnum=dnum/jz;xnumj = dnum+48;for(i = j;i=0;i-)printf(%c,xnumi);if(dnum - num != 0)printf(.);num = num - (int)num;doe+;printf(%c,(int)(num*jz)+48);num = num*jz-(int)(num*jz);if(num = 0)break;while(e20);double xtod(char num,int jz)double dnum = 0;int i,j,k=0,n=0,b;for(i=0;i+)if(numi=0)break;else n+;if(numi=.)j=i;k=1;for(i=j-1;i=0;i-)dnum =dnum + (double)(numj-i-1-48)*pow(jz,i);if(k=1)for(i=j+1;in;i+)if(numi=A) b=10;else if(numi=B) b=11;else if(numi=C) b=12;else if(numi=D) b=13;else if(numi=E) b=14;else if(numi=F) b=15;else b=numi-0;dnum=dnum+b*pow(jz,-(i-j);return dnum;void main()char num100;double dnum;int jz1,jz2;printf(intput one data);scanf(%s,num);printf(输入数为几进制);scanf(%d,&jz1);printf(转换为几进制);scanf(%d,&jz2);dtox(xtod(num,jz1),jz2