返回列表 發帖
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a,b, bong;
  6.     cout<<"Enter two random whole numbers: ";
  7.     cin>>a>>b;
  8.    
  9.     bong=a<b?a:b;
  10.     cout<<a<<"&"<<b<<"'s greatest common factor: ";
  11.     for(int i=bong;i>=1;i--)
  12.     {
  13.             if(a%i==0 && b%i==0)
  14.             {
  15.                       cout<<i<<" ";
  16.                       break;
  17.                       }
  18.                       }
  19.                       system("pause");
  20.                       return 0;
  21. }
複製代碼

TOP

返回列表