最大公约数算法(待续)

#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
*/

 

posted @ 2015-12-05 01:34  qlky  阅读(152)  评论(0编辑  收藏  举报