标签:style blog color os io for div amp
#include<iostream> using namespace std; int main() { int m,n,Max; int temp1,temp2; cout<<"please input two numbers:"<<endl; cin>>m>>n; Max=(m>n)?m:n; for(int i=1;i<Max;i++) { if(m%i==0&&n%i==0) { temp1=i; } } cout<<"最大公约数为:"<<temp1<<endl; temp2 = m * n / temp1;//最小公倍数的简便计算方法 cout<<"最小公倍数为:"<<temp2<<endl; return 0; }
55.输入两个正整数m和n,求其最大公约数和最小公倍数,布布扣,bubuko.com
标签:style blog color os io for div amp
原文地址:http://www.cnblogs.com/jixiaowu/p/3905124.html