- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a, b, c,smaller;
- cout<<"請輸入第一個數: ";
- cin>>a;
- cout<<"請輸入第二個數: ";
- cin>>b;
- cout<<"請輸入第三個數: ";
- cin>>c;
- smaller=(a<b)?a:b;
- smaller=(a<c)?a:c;
- smaller=(c<b)?c:b;
- for(int i=1; i<=smaller; i++)
- {
- if(a%i==0 && b%i==0 && c%i==0)
- cout<<i<<" ";
- }
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |