c语言编程练习题:7-112 约分最简分式
作者:yunjinqi   类别:    日期:2023-05-31 11:45:05    阅读:139 次   消耗积分:0 分    

image.png

#include <stdio.h>
int gcd(int a,int b)
{
	if(a<b)
		return gcd(b,a);
		
	if(a%b==0)
		return b;
	else
		gcd(b,a%b);
}
int main(){
    int a,b;
    if (scanf("%d/%d",&a,&b)!=EOF){
        // 分析不敲钟的时间
        int gcd_value = gcd(a,b);
        printf("%d/%d",a/gcd_value,b/gcd_value);
        
    }
    else{
        printf("input wrong");
    }
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/237
上一篇:c语言编程练习题:7-111 求特殊方程的正整数解
下一篇:c语言编程练习题:7-113 单词长度