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

TOP

返回列表