首页
开源
资讯
活动
开源许可证
软件工程云服务
软件代码质量检测云服务
持续集成与部署云服务
社区个性化内容推荐服务
贡献审阅人推荐服务
群体化学习服务
重睛鸟代码扫描工具
登录
注册
代码拉取完成,页面将自动刷新
Watch
1
Star
0
Fork
0
苏今歌
/
面向对象程序设计
Fork 仓库
加载中
取消
确认
代码
Issues
4
Pull Requests
0
Wiki
0
统计
更新失败,请稍后重试!
Issues
/
详情
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
重载函数
待办的
#IAYQSW
苏今歌
拥有者
创建于
2024-10-21 21:41
``` #include <iostream> using namespace std; int gcd(int a, int b) { if (a % b == 0) { return b; } else return gcd(b, a % b); } int commonDivisor(int x1, int x2) { int m = x1; m = gcd(m, x2); return m; } int commonDivisor(int x1, int x2, int x3) { int m = x1; m = gcd(m, x2); m = gcd(m, x3); return m; } int commonDivisor(int x1, int x2, int x3, int x4) { int m = x1; m = gcd(m, x2); m = gcd(m, x3); m = gcd(m, x4); return m; } int main() { int x1, x2, x3, x4, y; cout << "请输入2个整数:"; cin >> x1 >> x2; y = commonDivisor(x1, x2); cout << "整数" << x1 << "," << x2 << "的最大公约数为:" << y << endl; cout << "请输入3个整数:"; cin >> x1 >> x2>> x3; y = commonDivisor(x1, x2, x3); cout << "整数" << x1 << "," << x2 <<","<<x3 << "的最大公约数为:" << y << endl; cout << "请输入4个整数:"; cin >> x1 >> x2 >> x3 >>x4; y = commonDivisor(x1, x2, x3, x4); cout << "整数" << x1 << "," << x2 << "," << x3 <<","<< x4 << "的最大公约数为:" << y << endl; } ```
``` #include <iostream> using namespace std; int gcd(int a, int b) { if (a % b == 0) { return b; } else return gcd(b, a % b); } int commonDivisor(int x1, int x2) { int m = x1; m = gcd(m, x2); return m; } int commonDivisor(int x1, int x2, int x3) { int m = x1; m = gcd(m, x2); m = gcd(m, x3); return m; } int commonDivisor(int x1, int x2, int x3, int x4) { int m = x1; m = gcd(m, x2); m = gcd(m, x3); m = gcd(m, x4); return m; } int main() { int x1, x2, x3, x4, y; cout << "请输入2个整数:"; cin >> x1 >> x2; y = commonDivisor(x1, x2); cout << "整数" << x1 << "," << x2 << "的最大公约数为:" << y << endl; cout << "请输入3个整数:"; cin >> x1 >> x2>> x3; y = commonDivisor(x1, x2, x3); cout << "整数" << x1 << "," << x2 <<","<<x3 << "的最大公约数为:" << y << endl; cout << "请输入4个整数:"; cin >> x1 >> x2 >> x3 >>x4; y = commonDivisor(x1, x2, x3, x4); cout << "整数" << x1 << "," << x2 << "," << x3 <<","<< x4 << "的最大公约数为:" << y << endl; } ```
评论 (
0
)
苏今歌
创建了
任务
登录
后才可以发表评论
状态
待办的
待办的
进行中
已完成
已关闭
负责人
未设置
标签
未设置
标签管理
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
未关联
master
develop
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
参与者(1)