#include <iostream>
using namespace std;
int main()
{
int N,k=0;
cout<<"請輸入一個數 程式將找出1~該數中間所有的質數"<<endl;
cin>>N;
for(int i=2;i<=N;i++)
{
for(int j=2;j<i;j++)
if(i%j==0)
k++;
if(k!=0)
k=0;
else
cout<<i<<" ";
}
system("PAUSE");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.241.88