• 2644 求最大公约数

    Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 65536/32768 KB(Java/Others)

    Submits : 14603 | Solved : 9076

    Description

    设计函数,计算两个整数的最大公约数


    Input

    主函数中输入两个整数


    Output

    设计函数计算最大公约数,并在主函数中进行输出。


    Sample Input

    6 8

    Sample Output

    The gcd of 6 and 8 is 2

    Template

    #include<stdio.h>
    @-@
    
    int main()
    {
    int a,b;
    int g;
    scanf("%d%d",&a,&b);
    g=gcd(a,b);
    printf("The gcd of %d and %d is %d\n",a,b,g);
    return 0;
    }

    HINT

    程序填空题,模板中@-@的位置是需要填空的部分。

    Source

    NBU OJ

    [ Top ] | [ Submit ] | [ Statistics ] | [ Standing ]