1 #include <stdio.h>
2
3 int main()
4 {
5 int m , n, i ,j;
6 int quotient[1010];
7 int remainder[1001];
8 printf("Please input a fraction (m/n)(<0<m<n<=100):");
9 scanf("%d/%d", &m, &n);
10 printf("%d/%d it's accuracy value is: 0.", m ,n);
11 for (i = 1; i <= 100; i++)
12 {
13 remainder[m]=i;
14 m*=10;
15 quotient[i]=m/n;
16 m = m%n;
17 if (0 ==m)
18 {
19 for (j =1 ;j <= i; j++)
20 printf("%d", quotient[j]);
21 break;
22 }
23 if (remainder[m]!=0)
24 {
25 for (j = 1; j <= i; j++)
26 printf("%d", quotient[j]);
27 printf("\n\tand it is a infinite cuclic fraction from %d\n", remainder[m]);
28 printf("\tdigit to %d digit after decimal point.\n", i);
2
3 int main()
4 {
5 int m , n, i ,j;
6 int quotient[1010];
7 int remainder[1001];
8 printf("Please input a fraction (m/n)(<0<m<n<=100):");
9 scanf("%d/%d", &m, &n);
10 printf("%d/%d it's accuracy value is: 0.", m ,n);
11 for (i = 1; i <= 100; i++)
12 {
13 remainder[m]=i;
14 m*=10;
15 quotient[i]=m/n;
16 m = m%n;
17 if (0 ==m)
18 {
19 for (j =1 ;j <= i; j++)
20 printf("%d", quotient[j]);
21 break;
22 }
23 if (remainder[m]!=0)
24 {
25 for (j = 1; j <= i; j++)
26 printf("%d", quotient[j]);
27 printf("\n\tand it is a infinite cuclic fraction from %d\n", remainder[m]);
28 printf("\tdigit to %d digit after decimal point.\n", i);
29 break;
30 }
31 }
32 return 0;
33 }
[root@localhost 47]# vim fraction_accuracy_value.c
[root@localhost 47]# ./a.out
Please input a fraction (m/n)(<0<m<n<=100):25/96
25/96 it's accuracy value is: 0.260416
and it is a infinite cuclic fraction from 6
digit to 6 digit after decimal point.
[root@localhost 47]# ./a.out
Please input a fraction (m/n)(<0<m<n<=100):23/87
23/87 it's accuracy value is: 0.2643678160919540229885057471
and it is a infinite cuclic fraction from 1
digit to 28 digit after decimal point.