酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

C++实现输入三个数字求最小公倍数

```cpp #include <iostream> using namespace std; // 求两个数的最大公约数 int gcd(int x, int y) { while (y != 0) { int temp = y; y = x % y; x = temp; } return x; } // 求两个数的最小公倍数 int lcm(int x, int y) { return x / gcd(x, y) * y; } int main() { int a, b, c; cin >> a >> b >> c; // 先求a和b的最小公倍数,再求这个结果和c的最小公倍数 int result = lcm(lcm(a, b), c); cout << result << endl; return 0; } ``` ######[AI问答 | 203点数解答 | 2026-05-09 20:14:33]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]