美文网首页
练习2-5-8:求最小公倍数和最大公约数(多分支结构,简单循环结

练习2-5-8:求最小公倍数和最大公约数(多分支结构,简单循环结

作者: 笑笑xx | 来源:发表于2021-12-28 23:18 被阅读0次

    #include<stdio.h>

    int main()

    {

        int m,n,a,b,t,temp,h;

        scanf("%d%d",&m,&n);

        a=m;

        b=n;

        if(a<b)

        {

            t=a;

            a=b;

            b=t;

        }

        while(b!=0)

        {

            temp=a%b;

            a=b;

            b=temp;

        }

        h=m*n/a;

        printf("the greatest commom divisor:%d\n",a);

        printf("the minimum common multiple:%d\n",h);

        return 0;

    }

    相关文章

      网友评论

          本文标题:练习2-5-8:求最小公倍数和最大公约数(多分支结构,简单循环结

          本文链接:https://www.haomeiwen.com/subject/kyimqrtx.html