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

TOP

返回列表