码迷,mamicode.com
首页 > 其他好文 > 详细

gcd()

时间:2017-03-07 17:02:03      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:color   nbsp   long   std   iostream   turn   gcd   stream   end   

 1 #include <iostream>
 2 
 3 using namespace std;
 4 #define LL long long
 5 LL gcd(LL a, LL b)
 6 {
 7     if(a < b)
 8     {
 9         LL t = a;
10         a = b;
11         b = t;
12     }
13     return b==0?a:gcd(b, a%b);
14 }
15 int main()
16 {
17     LL a,b;
18     while(cin >> a >> b)
19     {
20         cout  << gcd(a,b) << endl;
21     }
22     return 0;
23 }

 

gcd()

标签:color   nbsp   long   std   iostream   turn   gcd   stream   end   

原文地址:http://www.cnblogs.com/jxust-jiege666/p/6515440.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!