int yue(int num1,int num2) { if(num1 < num2)//交换 { num1 ^= num2; num2 ^= num1; num1 ^= num2; } while(num1 % num2 != 0) { int temp = num1; num1 = num2; num2 = temp % num2; } return num2; } int bei(int num1,int num2) { return num1 * num2 / yue(num1,num2); } int main() { int num1,num2; printf("输入两个整数:\n"); scanf("%d %d",&num1,&num2); printf("两个数的最大公约数为:%d\n",yue(num1,num2)); printf("两个数的最小公倍数:%d\n",bei(num1,num2)); return 0; }