首页 > 技术文章 > 最大公约数算法(待续)

qlky 2015-12-05 01:34 原文

#include<iostream>
#include<string>
#include<cstring>
using namespace std;


int gcd(int x,int y)
{
          if(!y)
                    return x;
          else
                    return gcd(y,x%y);
}

int main()
{
          int t;
          cin>>t;
          while(t--)
          {
                    int a,b;
                    cin>>a>>b;
                    cout<<gcd(a,b)<<endl;
          }
}
/*
4
2 8
8 4
72 60
9 7
*/

 

推荐阅读