作者在 2012-10-28 16:30:35 发布以下内容
//:最大公约数,最小公倍数
#include <stdio.h>
int main(){
int num1, num2, temp;
int a, b;
printf("input two numbers:");
scanf("%d%d", &num1, &num2);
if(num1 < num2){
temp = num1;
num1 = num2;
num2 = temp;
}
a = num1, b = num2;
while(b){
temp = a%b;
a = b;
b = temp;
}
printf("最大公约数:%dn", a);
printf("最小公倍数:%dn", num1*num2/a);
return 0;
}
#include <stdio.h>
int main(){
int num1, num2, temp;
int a, b;
printf("input two numbers:");
scanf("%d%d", &num1, &num2);
if(num1 < num2){
temp = num1;
num1 = num2;
num2 = temp;
}
a = num1, b = num2;
while(b){
temp = a%b;
a = b;
b = temp;
}
printf("最大公约数:%dn", a);
printf("最小公倍数:%dn", num1*num2/a);
return 0;
}