我的一个c语言程序,践行!

时间:2023-02-21 10:17:15

#include<stdio.h>

int yue_fen(int a,int b)

{

int z;

if(a==0)

z=b;

if(a<0)

a=-a;

if(b<0)

b=-b;

while(a!=0)

{

z=b%a;

b=a;

a=z;

}

return b;

}

int main(void)

{

int x,y;

printf("enter a fraction");

scanf("%d/%d",&x,&y);

x=x/yue_fen(x,y);

y=y/yue_fen(x,y);

printf("in lowest terms%d/%d",x,y);

return 0;

}