返回列表 發帖
本帖最後由 張絜晰 於 2023-3-17 21:02 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {  
  6.    int a,b,f=0;
  7.    cout<<"請輸入兩個整數:";
  8.    cin>>a>>b;
  9.    while(a%b!=0){
  10.    f=a%b;
  11.    a=b;
  12.    b=f;
  13. }
  14.    cout<<a<<"和"<<b<<"的最大公因數是"<<b<<endl;
  15.    system("pause");
  16.    return 0;   
  17. }
複製代碼
Attention Seeker </3

TOP

返回列表