1 #include<iostream> 2 using namespace std; 3 int gcd(int a,int b){ 4 if(a>b){ 5 if(a%b!=0) return gcd(b,a%b); 6 else return b; 7 } 8 else gcd(b,a); 9 } 10 int main(){ 11 int a,b; 12 while(cin>>a>>b) 13 cout<<gcd(a,b)<<endl; 14 return 0; 15 }
原文地址:http://www.cnblogs.com/acplayfacm/p/3863899.html