c语言编程练习题:7-26 最大公约数和最小公倍数
作者:yunjinqi   类别:    日期:2023-05-29 13:30:58    阅读:123 次   消耗积分:0 分    

image.png

#include <stdio.h>
int main(){
    int a,b,c=1,d=1,i=1;
    if (scanf("%d %d",&a,&b)!=0){
        while (d==1){
            if (a%i==0 && b%i==0){c = i;}
            if (i%a==0 && i%b==0){d = i;}
            i++;
        }
        printf("%d %d",c,d);
    }else{
        printf("something wrong");
    }
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/151
上一篇:c语言编程练习题:7-25 求奇数和
下一篇:c语言编程练习题:7-27 兔子繁衍问题