运行不了,大家帮我看看怎么修改,怎么初始化呀,还有最小公倍数怎么算呀,我这段代码最小公倍数那里发生运行错误

设计一个函数里头元素也要初始化嘛,怎么初始化呀 题目如下 然后我写的代码在下面

img

#include
int f(intx, inty)
{
int t, x, y;
x = 0, y = 0;
while (y != 0) {
t = x % y;
x = y;
y = t;

}
printf("这两个数的最大公约数是%d\n", x);
return 0;

}
int g(intx, inty)
{
int t, x, y, a, b;
x = 0, y = 0;
a = x, b = y;
while (y != 0) {
t = x % y;
x = y;
y = t;
}
printf(" % d和 % d的最小公倍数是 % d\n", a, b, a * b / x);
return 0;
}
int inNumber(int x) {
scanf_s("%d", &x);
while (x <= 0)
{
scanf_s("%d", &x);
}return x;

}
int main() {
int a,b,c, d,x=0;
a = inNumber(x);
b = inNumber(x);
c = f(10, 25);
d = g(20, 25);

}
return0;

改动处见注释,供参考:

#include <stdio.h>
int f(int x, int y)
{
    int t;  //, x, y;
            //x = 0, y = 0;
    while (y != 0) {
        t = x % y;
        x = y;
        y = t;

    }
    //printf("这两个数的最大公约数是%d\n", x);
    return  x;  //return 0;
}
int g(int x, int y)
{
    int t, a, b;  // x, y,
                  //x = 0, y = 0;
    a = x, b = y;
    t = a * b / f(x, y);
    //while (y != 0) {
    //    t = x % y;
    //    x = y;
    //    y = t;
    //}
    //printf(" % d和 % d的最小公倍数是 % d\n", a, b, t); // a, b, a * b / x);
    return t; //return 0;
}
int inNumber(int x) {
    scanf_s("%d", &x);
    while (x <= 0){
        scanf_s("%d", &x);
    }return x;
}
int main() {
    int a, b, c, d, x = 0;
    a = inNumber(x);
    b = inNumber(x);
    c = f(a, b); //f(10, 25);
    d = g(a, b); //g(20, 25);
    printf(" %d和 %d的最小公倍数是 %d,最大公约数是 %d\n", a, b, d, c); // a, b, a * b / x);
    return 0;
}

你f g函数里的x,y为什么一上来就要赋值0呀,一赋值为0后边的循环不就进不去了吗?