题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
#include <iostream>
using namespace std;
int main() {
int a, b, c,s;
cin >> a >> b;
if (a > b )
{
c = b;
b = a;
a = c;
}
s = a*b;
for (c = b;c <= s; c++)
{
if ((c%a==0)&&(c%b==0))
{
cout << c <<endl;
break;
}
}
return 0;
}
查看12道真题和解析
