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

TOP

返回列表