题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

#include <iostream>
using namespace std;

int func(int& res, const int& a, const int& b) {
    if (res % a == 0 && res % b == 0) {
        return res;
    } else {
        res++;
        func(res, a, b);
    }
    return -1;
}

int main() {
    int a, b;
    cin >> a >> b;
    int res = 1;
    func(res, a, b);
    cout << res << endl;
}

使用引用传出结果

全部评论

相关推荐

985柜员:开发还敢还叫,全部让自测就老实了
点赞 评论 收藏
分享
03-12 09:57
软件测试
程序员小白条:1)确定测试,测开的方向,技术栈不能写这么少 2)课程凑数的,不是99,100分没必要写 3)实习经历这块要有突出的不是劳动性质的亮点,自己设计的什么方案,什么自动化?什么提效工具?不是一些边角料,人云亦云的东西,没吸引力 4) 校园经历纯没用 5)尽量少写减分项
听劝,我这个简历该怎么改...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务