程序只验证了样例
1 #include<stdio.h> 2 3 int q, r; //全局变量 4 int div(int a, int b); 5 int main(void) 6 { 7 int a, b; 8 int count = 0; 9 10 scanf("%d/%d", &a, &b); 11 printf("0."); 12 do 13 { 14 div(a, b); 15 printf("%d", q); 16 count++; 17 if (count == 200) 18 { 19 break; 20 } 21 a = r; 22 } while(r != 0); 23 } 24 25 int div(int a, int b) 26 { 27 q = a * 10 / b; 28 r = a * 10 % b; 29 }