34:最大公约数

#include<iostream>
#include<algorithm>
using namespace std;
int a,b;
int gcd(int a,int b)
{
    if(a%b==0) return b;
    else return gcd(b,a%b);
} 
int main()
{
    while(cin>>a>>b)
    {
        if(a<b) swap(a,b);
        cout<<gcd(a,b)<<endl;
    }
}

 

posted @ 2016-01-28 12:12  OZTOET  阅读(250)  评论(0)    收藏  举报