View Code of Problem 59

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	while(1){
	int a,b,n1,n2,team;
	scanf("%d %d",&a,&b);
	if(a<b){
	team=a;
	a=b;
	b=team;
	}
	n1=a;
	n2=b;
	while(b!=0){
	team=a%b;
	a=b;
	b=team;
	}
	printf("最大公约数:%d\n",a);
	printf("最小公倍数为:%d\n",n1*n2/a);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 59