返回列表 發帖
  1. #include<iostream>
  2. using namespace std;

  3. int main(){
  4.     int x, y;
  5.     cout<<"請輸入第一個數: ";
  6.     cin>>x;
  7.     cout<<"請輸入第二個數: ";
  8.     cin>>y;
  9.     int smaller=x<y?x:y;
  10.     for(int i=1; i<=smaller; i++){
  11.         if(x%i==0 and y%i==0){
  12.             cout<<i<<" ";
  13.         }
  14.     }
  15.    
  16.     cout<<"\n";
  17.     system("pause");
  18.     return 0;
  19. }
複製代碼

TOP

返回列表