返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int g, h, f, z;
  7.     cout<<"請輸入第一個正整數: ";
  8.     cin>>g;
  9.     cout<<"請輸入第二個正整數: ";
  10.     cin>>h;
  11.     f=g<h?g:h;
  12.     for(int i; i<=0; i--)
  13.     {
  14.         if(g%i==0 && h%i==0)
  15.         {
  16.             z=i;
  17.             break;
  18.         }
  19.     }
  20.     cout<<g<<"和"<<h<<"的最大公因數: "<<endl;
  21.     cout<<z<<endl<<endl;
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

TOP

返回列表