首页 > 其他 > 详细

最大公约数

时间:2015-01-05 11:09:23      阅读:231      评论:0      收藏:0      [点我收藏+]
#include<iostream>
using namespace std;

int gcd(int m, int n)
{
    int temp = 0;
    if (m < n)
    {
        temp = m;
        m = n;
        n = temp;
    }
    while (0 != m%n)
    {
        temp = n;
        n = m%n;
        m = n;
    }
    return n;
}

int main()
{
    int m =0, n =0;
    cin>>m>>n;
    cout<<gcd(m, n)<<endl;
    return 0;
}

最大公约数

原文:http://blog.csdn.net/xiaohanstu/article/details/42419723

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!