c及c++求最大公因數及最小公倍數@ Just do it!! - 隨意窩

文章推薦指數: 80 %
投票人數:10人

已用Dev-C++ 4.9.9.2測試過=== C===#include #include int gcd(int x,int y);int main(void){ int a,b; printf("請輸入2數字以求出最大公因數及 ... Justdoit!!學而不思則罔,思而不學則殆^^日誌相簿影音好友名片 201003300243c及c++求最大公因數及最小公倍數?C&C++已用Dev-C++4.9.9.2測試過===  C===#include#includeintgcd(intx,inty);intmain(void){   inta,b;   printf("請輸入2數字以求出最大公因數及最小公倍數:");   scanf("%d%d",&a,&b);   printf("gcd(%d,%d)=%d\n",a,b,gcd(a,b));   printf("lcm(%d,%d)=%d\n",a,b,(a*b)/gcd(a,b));   system("PAUSE");      return0;}intgcd(intx,inty){   if(x!=0&&y!=0)      returngcd((x>=y)?x%y:x,(x#includeintgcd(intx,inty);usingnamespacestd;intmain(void){   inta,b;   cout<>a>>b;   cout<=y)?x%y:x,(x



請為這篇文章評分?