The problem is to convert the decimal to decimal decimals, the problem requirements, eight decimal point after the 15-bit drunk, so that the number of decimal in the most have 45, so directly do not work.
#include <iostream>
#include <string>
using namespace Std;
int main ()
{
int i,j,k;
String str;
while (CIN>>STR)//Enter octal decimal
{
K=str.size ();
int a[100]={0};
int index=0;
for (i=k-1;i>=2;i--)
{
int num=str[i]-' 0 ';
for (j=0;num!=0| | j<index;j++)//from the back to the decimal position out, so that each decimal multiplied by 10 and then add the above calculated to leave the number of decimal places to 8 modulo
{
num=10*num+ (j<index?a[j]:0); A[J] corresponds to the number of decimal places left in the previous step,
A[J]=NUM/8;
num=num%8; In 0.75, for example, 50+0 divided by 8 to get the a[0]=6,a[1]=2,a[2]=5, the second part of the loop, num=7, and then a[0]=7*10+6=9,a[1]=4*10+2=5,a[2]=2*10+5=3,a[3]=1*10+0=1,a[4]=2*10+0=2;a[5]=4*10+0=5;
The final output 0.A[0]A[1]A[2]A[3]A[4]A[5] is the decimal decimal number that is obtained. That is 0.953125
}
Index=j;
}
cout<<str<< "" << "[8] =" << "0.";
for (i=0;i<index;i++)
cout<<a[i];
cout<< "[A]" <<endl;
}
}