题解 | #最大公约数#

最大公约数

http://www.nowcoder.com/practice/20216f2c84bc438eb5ef05e382536fd3

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
        int temp=a%b;
        while(temp){
            a=b;
            b=temp;
            temp=a%b;
        }
        printf("%d\n",b);
    }
    return 0;
}

全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务