返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {  
  6.    int a,b,c=0,d=0,f=0;
  7.    cout<<"請輸入兩個整數:";
  8.    cin>>a>>b;
  9.    cout<<a<<"和"<<b<<"的最大公因數為:";
  10.    while(a%b!=0){
  11.    f=a%b;
  12.    a=b;
  13.    b=f;        
  14.                  }
  15.    cout<<b<<endl;
  16.    system("pause");
  17.    return 0;   
  18. }
複製代碼

TOP

返回列表