关于#c语言#的问题:将浮点数转化为分数,我想实现输入一个浮点数 ,将小数部分转化为最简分数的形式,输出分子和分母

输入一个小于1的浮点数没问题,但输入一个大于1的就没有结果


#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int aes(double x);
    int zdgys(int x,int y);
    double a,c;
    int b,n,i;
    int fz=0,fm=1;
    scanf("%lf",&a);
    b=a;
    c=a-b;
    n=aes(c);
    fz=pow(10,n)*c;
    fm=pow(10,n);
    int t;
    t=zdgys(fm,fz);
    printf("%d %d %d\n",b,fz/t,fm/t);
    return 0;
}

int aes(double x)
{
    double z;
    int y,i=0;
    do{
        x*=10;
        y=x;
        z=x-y;
        i++;
    }while(z!=0);
    return(i);
}

int zdgys(int x,int y)
{
    int t1;
    do{
        t1=x%y;
        x=y;
        y=t1;
    }while(t1!=0);
    return(x);
}

可以参考一下
https://blog.csdn.net/qq_54121864/article/details/112971641