返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     long a;
  8.     cout<<"請輸入一個正整數:";
  9.     cin>>a;
  10.     cout<<a<<"ㄉ因數有:";
  11.     long i=1;
  12.     while(i<=a)
  13.     {
  14.         if(a%i==0)
  15.         {
  16.             
  17.             cout<<i<< " ";
  18.         }
  19.         i++;
  20.     }
  21.     goto re;
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     long a;
  8.     cout<<"請輸入一個正整數:";
  9.     cin>>a;
  10.     cout<<a<<"ㄉ因數有:";
  11.     long i=1;
  12.     while(i<=a)
  13.     {
  14.         if(a%i==0)
  15.         {
  16.             
  17.             cout<<i<< " ";
  18.         }
  19.         i++;
  20.     }
  21.    
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

TOP

返回列表