- #include "stdafx.h"
- #include<iostream>
- using namespace std;
- int main()
- {
- int a,b,m,n;
- cout<<"please input two numbers:\\n";
- cin>>a>>b;
- if(a < b)
- {
- int temp;
- temp = a;
- a = b;
- b = temp;
- }
- m = a * b;
- n = a % b;
- while(n != 0)
- {
- a = b;
- b = n;
- n = a % b;
- }
- cout<<"the max commen divistor: "<<b<<endl;
- cout<<"the min commen multiple: "<<m/b<<endl;
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/2309201410505.html
来源: http://www.codesnippet.cn/detail/2309201410505.html