[推荐]用欧几里德算法实现最大公因子
#include <iostream> using namespace std; int main() { int r = -1,m = 119,n = 544; if (m < n) { int temp = m; m = n,n = temp; } while (r != 0) { r = m % n; if (r == 0) break; else m = n,n = r; } cout << n << endl;
return 0; }
[此贴子已经被作者于2004-05-05 11:14:22编辑过]