25 lines
316 B
C++
25 lines
316 B
C++
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
|
||
|
int main(){
|
||
|
int n,m,x;
|
||
|
|
||
|
cout << "请输入两个数:";
|
||
|
cin >> n >> m;
|
||
|
|
||
|
if (m>n)
|
||
|
{
|
||
|
x = n;
|
||
|
}else
|
||
|
{
|
||
|
x = m;
|
||
|
}
|
||
|
|
||
|
while ( n%x!=0 || m%x!=0)
|
||
|
{
|
||
|
x--;
|
||
|
}
|
||
|
|
||
|
cout << "最大公约数为:" << x << endl;
|
||
|
return 0;
|
||
|
}
|