标签:
#include<iostream>
using namespace std;
int main(void)
{
int x, y, num1, num2, temp;
printf("请输入两个正整数:\n");
scanf("%d %d", &num1, &num2);
if(num1 < num2)//交换
{
num1^=num2;
num2^=num1;
num1^=num2;
}
x = num1;
y = num2;//让num1,num2值不变
while(y != 0)
{
temp = x%y;
x = y;
//cout<<"x="<<x<<endl;
y = temp;
//cout<<"x="<<y<<endl;
}
printf("它们的最大公约数为:%d\n", x);
printf("它们的最小公倍数为:%d\n", num1*num2/x);
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/a819721810/article/details/46843785