您的位置:首页 > 其它

求最大公约数

2016-03-25 18:00 260 查看
 *copvriqht(c)2016,烟台大学计控学院

 *All rights re
4000
served.

 *文件名称:test.cpp

 *作者:张全伟

 *完成日期:2016年3月25日

 *版本号:codeblocks1.6;

 *

*/

#include <iostream>

using namespace std;

int gcd(int x,int y);

int main()

{

   int a,b,c;

   cin>>a>>b;

   g=gcd(a,b);

   cout<<"最大公约数是"<<c;

   return 0;

}

int gcd(int x,int y)

{

    int n,i;

    if(x>y)

        n=y;

    else

        n=x;

    for(n=i;i>=1;i--)

    {

        if(x%i==0&&y%i==0)

            return i;

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: