一、问题描述:
二、设计思路:
三、程序流程图:
真不想写这个,鸡肋且麻烦,除非是大项目
四、代码实现:
#include<stdio.h> int main() { int M,N,i,j; int a[101]={0};//存除法的余数 int b[101]={0};//依次存钱商的每一位 printf("Please input a fraction(M/N)(<0<M<N<=100):"); scanf("%d/%d",&M,&N); printf("%d/%d it's accuracy value is:0.",M,N); for(i=1;i<=100;i++) { a[M]=i; M*=10; b[i]=M/N; M=M%N; if(M==0) { for(j=1;j<=i;j++) { printf("%d",b[j]); } break; } if(a[M]!=0)//若该余数在前面已经出现过 { for(j=1;j<=i;j++) printf("%d",b[j]); printf("\n\tand it is infinite cyclic fraction from %d\n",a[M]); printf("\tdigit to %d digit after decimal point.\n",i); break; } } return 0; }
标签:分数,精确,int,Please,计算,printf,101 From: https://www.cnblogs.com/bzsc/p/17453785.html