返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int a,b,c;
  8.     cout<<"請依序輸入兩個正整數: ";
  9.     cin>>a>>b;
  10.     cout<<a<<"與"<<b<<"的最大公因數是: ";
  11.     while(a%b!=0)
  12.     {
  13.         c=a%b;
  14.         a=b;
  15.         b=c;
  16.         
  17.     }
  18.     cout<<b<<endl<<endl;
  19.     goto re;
  20.     system("pause");
  21.     return 0;   
  22. }
複製代碼
李宇澤Oscar

TOP

返回列表