求两个数的最大公约数

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int Gcd(int a,int b){
 5     if(a%b==0) return b;
 6     else return Gcd(b,a%b);
 7 }
 8 
 9 int main(){
10     int a,b;
11     while(cin>>a>>b)
12         cout<<Gcd(a,b)<<endl;
13     return 0;
14 }

 

posted @ 2018-07-26 16:49  gzu_zb  阅读(196)  评论(0编辑  收藏  举报