返回列表 發帖
本帖最後由 張健勳 於 2016-1-30 11:35 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int y=0;
  7.      for(int x = 2; x <= 100000; x++)
  8.      {
  9.         int i = 2;
  10.         while(x >= i)
  11.         {
  12.            if(x == i)
  13.            {               
  14.               y++;
  15.            }               
  16.            else if((x % i)== 0)
  17.            {
  18.                break;                    
  19.            }
  20.            i++;
  21.            }
  22.         }
  23.         cout<<"有"<<y<<"顆植樹"<<endl;
  24.         system("pause");
  25.         return 0;
  26.    }
複製代碼

TOP

返回列表