//辗转相除法 最大公因数 + 最小公倍数 #include<stdio.h> void yinshu(int a,int b){ int temp; while(a % b != 0){ temp = a; a = b; b = temp % b; } printf("%d\n",b); } void beishu(int a,int b){ int a1 =a; int b1 = b; int t; while(a%b != 0){ t = a; a= b; b = t % b; } printf("%d",a1/b*b1); } int main(){ int a,b; scanf("%d %d",&a,&b); yinshu(a,b); beishu(a,b); return 0; }
原文地址:https://www.cnblogs.com/expedition/p/12005739.html
时间: 2024-10-17 02:40:10