[cpp]#include <stdio.h>

#include<iostream>

using namespace std;

int Z[100000];

int num, den;

int i=0;

void init();

int main()

{

cin>>num;

cin>>den;

int flag=0;

int num1 = num;

int den1 = den;

while(1)

{

flag=0;

int zb=0;

int digit=0;

cout<<num1<<"/"<<den1<<" = ";

init();

int check = num1/den1;

if(check > 0)

{

cout<<check<<".(";

int temp = check * den1;

num1 = num1 - temp;

}

else

cout<<"0.(";

int count = 0;

while(1)

{

count++;

num1=num1 * 10;

zb= num1 % den1;

if( zb == 0)

{

cout<<num1/den1;

cout<<")";

cout<<"\n"<<"\t1 = number of digits in repeating cycle\n";

flag=1;

}

if(flag==1)

{

break;

}

if( Z[num1] != -1 )

{

if(count > 50)

cout<<"...";

if(check <= 0)

cout<<")";

cout<<"\n\t"<<(digit-Z[num1])<<" = number of digits in repeating cycle\n";

flag=1;

}

if(flag==1)

{

break;

}

if(count <= 50)

cout<<num1/den1;

Z[num1]= digit;

num1 = num1%den1;

digit++;

}

i++;

cin>>num>>den;

num1 = num;

den1 = den;

}

return 0;

}

void init()

{

for(int i= 100000;i>0; i--)

{

Z

*= -1;*

}

}

}

}