#include <stdio.h> void main() { int a,b,n1,n2,t; printf("任意输入两个正整数: "); scanf("%d%d",&n1,&n2); if(n1<n2) { t = n1; n1 = n2; n2 = t; } a = n1; b = n2; while(b!=0) {/*利用辗转相除法,直到b为0为止*/ t = a%b; a = b; b = t; } printf("最大公约数为:%d ",a); printf("最大公倍数为:%d ",n1*n2/a); }