<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont

本文涉及的产品
转发路由器TR,750小时连接 100GB跨地域
简介: 解法一:---------------------------------------------------------------------------------------------------------...

解法一:------------------------------------------------------------------------------------------------------------

#include<iostream>
using namespace std;
int main(){
	int a, b,c,d,m,n;
	cout << "请输入第1个数:";
	cin >> a;
	cout << "请输入第2个数:";
	cin >> b;
	m = a > b ? a : b;
	n = a > b ? b : a;
	c = m*n;
	d = m% n;
	while (d){
		m = n;
		n = d;
		d = m%n;
	}
	c = c / n;
	cout << "这两个数的最大公约数为:" << n;
	cout << "" << endl;
	cout << "这两个数的最小公倍数为:" << c;
	cout << "" << endl;
}
解法二:------------------------------------------------------------------------------------------------------------
#include<iostream>
using namespace std;
int gcd(int a, int b){  //返回a,b最大公约数
	return (b>0) ? gcd(b, a%b) : a;   //若b大于a,则递归gcd(b, a%b)时,a和b会互换
}
int main(){
	int a, b, c, d, m, n;
	cout << "请输入第1个数:";
	cin >> a;
	cout << "请输入第2个数:";
	cin >> b;
	c = a*b;
	n = gcd(a,b);
	c = c / n;
	cout << "这两个数的最大公约数为:" << n;
	cout << "" << endl;
	cout << "这两个数的最小公倍数为:" << c;
	cout << "" << endl;
}

 
 

相关文章
|
Web App开发 前端开发 测试技术
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
一、迁移步骤 1.首先安装最新版本gitlab(gitlab7.2安装) 2.停止旧版本gitlab服务 3.将旧的项目文件完整导入新的gitlab   bundle exec rake gitlab:import:r...
726 0
|
Web App开发 前端开发 Java
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
 Connection reset by peer的常见原因: 1)服务器的并发连接数超过了其承载量,服务器会将其中一些连接关闭;    如果知道实际连接服务器的并发客户数没有超过服务器的承载量,看下有没有网络流量异常。
872 0
|
Web App开发 存储 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
NoSuchObjectException(message:There is no database named cloudera_manager_metastore_canary_test_db_hive_hivemetastore_df61080e04cd7eb36c4336f71b5a8bc4) at org.
1095 0
|
Web App开发 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
service cloudera-scm-agent stop service cloudera-scm-agent stop umount /var/run/cloudera-scm-agent/process umo...
775 0
|
Web App开发 前端开发 数据库
|
Web App开发 前端开发
|
Web App开发 前端开发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
在统计分析系统中, 维度:指人们分析事物的角度。比如,分析活跃用户,可以从时间的维度,也可以从地域的维度去看,也可以时间、地域两个维度组合去分析。
676 0
|
Web App开发 前端开发 程序员
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><meta http-equiv="Cont
如何建立一个“铁打的营盘”? 中国有句古话,叫做铁打的营盘流水的兵。   我相信,创业初期,当团队里有人离开的时候,肯定有不少创业者拿这句话来安慰自己。
832 0