最大公约数为辗转相除法求得, 最小公倍数为两数之积与最大公约数的比值

 #include<iostream>
using namespace std;
int gcd(int, int);
int mcm(int, int);
int main()
{
int a, b;
cout << "enter a and b: " << endl;
cin >> a >> b;
cout << "gcd : " << gcd(a, b) << endl;
cout << "mcm : " << mcm(a, b) << endl; system("pause");
return ;
}
int gcd(int a, int b)
{
while (a%b != )
{
int tmp = a;
a = b;
b = tmp % a;
}
return b;
}
int mcm(int a, int b)
{
return a * b / mcm(a, b);
}

最新文章

  1. CentOS6.7搭建LNMP环境
  2. Android调用WebService
  3. App Store2016年最新审核规则
  4. python logging bydate
  5. BZOJ4152The Captain[DIjkstra]
  6. 抽象类和抽象方法(关键字abstract)
  7. nodejs 5.2.0文档自翻译——HTTP模块
  8. android打包签名介绍
  9. eclipse最有用快捷键整理(转)
  10. R语言︱文本挖掘之中文分词包——Rwordseg包(原理、功能、详解)
  11. SQL Server 2008 下载及版本说明
  12. Python__装饰器练习题
  13. 三类设计模式UML图
  14. 1506.01186-Cyclical Learning Rates for Training Neural Networks
  15. Mac快捷键大全及cheatsheet插件
  16. Inception-v3的设计思路小结
  17. IDEA报错:Error starting ApplicationContext. To display the auto-configuration report re-run your application with &#39;debug&#39; enabled. (&#39;crmWatcherService&#39;错误)
  18. eclipse中Maven项目jar问题
  19. FFMPEG视音频编解码零基础学习方法 【荐】
  20. stl中的map经验

热门文章

  1. 【CF160E】Buses and People
  2. echarts实践用法
  3. vue设置全局query参数
  4. MongoDB学习笔记之文档
  5. MySQL--关于MySQL练习过程中遇到的AVG()函数处理空值的问题
  6. win10 1903 更改文字大小
  7. BZOJ 3173: [Tjoi2013]最长上升子序列 Splay
  8. OCWA提高组模拟赛一 Solution
  9. The 10 Statistical Techniques Data Scientists Need to Master
  10. 编译一个需要用特定key前面的应用程序