16.cpp
来自「经典C语言程序设计100例1-10 如【程序1】 题目:有1、2、3、4」· C++ 代码 · 共 28 行
CPP
28 行
/*---------------------------------------例题16-------------------------------------------------------------------*/
#include <iostream>
using namespace std;
int main()
{
int m, n;
cout<<"Please input the two numbers:"<<endl;
cin>>m>>n;
cout<<"m = "<<m<<'\t'<<"n = "<<n<<endl;
int store = m * n;//若求出了最大公约数,最小公倍数就很好求了.
while(m>0)
{
if(n>m)
{
int temp = m;
m = n;
n = temp;
}
m -= n;
}
cout<<"The greatest common divisor of the two numbers is: "<<n<<endl;
cout<<"The lease common multiple of the two numbers is: "<<store/n<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?