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

TOP

返回列表