最大公因数

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

 

posted @ 2021-01-02 22:38  丁帅帅dss  阅读(72)  评论(0)    收藏  举报