#include"cstdio"#include"string.h"int th[3005];
int ans[3005];
int main()
{
int a, b;
while (scanf("%d%d", &a, &b) != EOF)
{
int fir = a / b;
intx = (a % b) * 10;
int i = 0;
int len = 0;
int bre = 0;
while (1)
{
th[i] = x;//被除数
ans[i] = x / b;//运算的结果
int mod = x % b;//运算后的余数
for (int j = 0; j < i; ++j)
{
if (th[i] == th[j])//找到一个相同的被除数,后面就和前面某个部分一样了,可以判断循环了
{
bre = j;
len = i - j;
break;
}
}
if (len)break;
x = mod * 10; ++i;
}
printf("%d/%d = %d.", a, b, fir);
for (int i = 0; i < bre; ++i)
printf("%d",ans[i]);
printf("(");
if (len <= 50)
for (int i = bre; i < bre + len; ++i)
printf("%d", ans[i]);
elsefor (int i = bre; i < bre + 50; ++i)
{
printf("%d", ans[i]);
if (i == bre + 49)printf("...");
}
printf(")\n %d = number of digits in repeating cycle\n\n", len);
}
return0;
}
UVA - 202 Repeating Decimals(https://vjudge.net/problem/UVA-202)#include&amp;quot;cstdio&amp;quot;#include&amp;quot;string.h&amp;quot;int th[3005];int ans[3005];int main(){ int a, b; while (scanf(&amp;quot;%d%d&amp;qu