返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main ()
  5. {
  6.         int a, b, c;
  7.         cout<<"輸入兩個整數:";
  8.         cin>>a>>b;
  9.         int min=(a>b)? b:a;
  10.         for(int i=1;i<=min; i++)
  11.         {
  12.        
  13.                 if (a%i==0 && b%i==0)
  14.                 {
  15.                         cout << i << " ";
  16.                        
  17.         c =i;
  18.                 }
  19.         ;
  20.         }
  21.         cout<<endl;
  22.         cout<< c <<endl;
  23.        
  24.         system ("pause");
  25.         return 0;

  26. }
複製代碼

TOP

返回列表