Run ID:68482

提交时间:2024-03-23 14:56:50

#include <iostream> using namespace std; int CommFactor1(int m, int n); //函数的声明 int main() { int a, b; cin >> a >> b; cout << "这两个数的最大公约数为:" << CommFactor1(a,b)<< endl; return 0; } int CommFactor1(int m,int n) { int tem; for (tem = m;; tem--) { if (m % tem == 0 && n % tem == 0) { break; } } return tem; }