您的位置:首页 > 编程语言 > Go语言

欧几里得算法 Euclidean algorithm

2016-05-03 10:49 441 查看
突然发现我连int main里标准的参数都不会写。尴尬啊,哈哈哈哈…

// Euclidean algorithm
// 欧几里得算法
#include <iostream>
using namespace std;

int gcd(int p, int q)
{
if (q == 0) return p;
int r = p % q;
return gcd(q, r);
}

int main(int argc, char* argv[])
{
int a, b;
cout << "Enter two number for gcd calculation: ";
cin >> a >> b;

cout << gcd(a, b) << endl;

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