Home > database >  Converting decimal N into the system, including the integer and decimal
Converting decimal N into the system, including the integer and decimal

Time:10-23


Decimal conversion involves the integer and decimal, this program includes both merge processing, into the system is less than 10, more than a decimal display requires a separate processing, this program does not contain,
#include

Void Ton (double m, int n)
{
Int t;
Double s;
Char STR [10].
Char dou [10].
I=0;

T=(int) m;
S=m - t;

While (t!=0) {
STR=[i++] t % n;
T=t/n.
}
for(int j=0; J<10; J++) {
S *=n;
Dou [j]=(int) s;
S -=(int) s;
}

If (m==0) {
Printf (" % d ", m);
} else {
While (I - & gt; 0 {
Printf (" % d ", STR [I]);
}
Printf (" % c ", '. ');

for(int j=0; J<0; J++) {
Printf (" % d ", dou [j]);
}
printf("\n");
}
}


Int main ()
{
int n;
Double m;

While (scanf_s (lf "% % d", & amp; M, & amp; N)! EOF)={
if(! M & amp; & ! N) {
break;
}
Ton (m, n);
}
return 0;
}

CodePudding user response:

You'd better compile results and drying out the operation result
  • Related