返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   int a,d,s,m=0;
  7.   cout<<"請輸入第1個數:"<<endl;
  8.   cin>>a;
  9.   cout<<"請輸入第2個數:";
  10.   cin>>d;
  11.   s=(a<d)?a:d;
  12.   for(int q=1;q<=s;q++)
  13.   {
  14.      if(a%q==0&&d%q==0)     
  15.      {
  16.          m=q;
  17.      }   
  18.   }
  19.   cout<<m<<endl;
  20.     system("pause");
  21.     return 0;
  22. }
複製代碼

TOP

返回列表