返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.         system("cls");
  8.         int x,y=0;
  9.         for(int i=1; i<=100000; i++){
  10.             x=0;
  11.             for(int j=1; j<=i; j++){
  12.                 if(i%j==0)
  13.                     x++;
  14.             }
  15.         if(x==2)
  16.             y++;
  17.         }
  18.         cout<<"100000以下的質數有"<<y<<"個"<<endl;

  19.         system("pause");
  20.         goto re;
  21.         return 0;
  22. }
複製代碼

TOP

返回列表