返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {  
  6.    int a,b;
  7.    cout<<"請輸入兩個整數:";
  8.    cin>>a>>b;
  9.    int c;
  10.    if(a<b){
  11.    c=a;
  12.            }
  13.    else{
  14.    c=b;
  15.         }
  16.    cout<<a<<"和"<<b<<"的公英數有:";
  17.    for(int d=1;d<=c;d++){
  18.            if(a%d==0 and b%d==0){
  19.            cout<<d<<" ";
  20.                      }
  21.            }
  22.    system("pause");
  23.    return 0;   
  24. }
複製代碼

TOP

返回列表