最大公约数/最小公倍数


#include <iostream>
using namespace std;
int main()
{
	int a, b, temp1, temp2;
	int c;
	cout << "请按从大到小的顺序两个数字" << endl;
	cin >> a >> b;
	temp1 = a, temp2 = b;
	while (temp2 != 0)
	{
		c = temp1 % temp2;
		temp1 = temp2;
		temp2 = c;
	}
	cout <<"最大公约数是"<< temp1 << endl;
	cout << "最小公倍数是" << a / temp1 * b;
}

posted @ 2020-07-14 19:55  _Hsiung  阅读(53)  评论(0编辑  收藏  举报