📄 4_21.cpp
字号:
# include <iostream.h>
const int max =1000;
const int width =10;
void main()
{
bool s[max+1];
int i,n,col=0;
for (i=0;i<=max;i++)
s[i]=0;
s[0]=1;
cout<<max<<"以内的素数有:"<<endl;
for (n=1;n<=max;n++)
if (s[n-1]==0)
{
cout<<n<<" ";
if (++col>=width)
{
cout<<endl;
col=0;
}
for (i=n;i<=max;i+=n)
s[i-1]=1;
}
if (col!=0)
cout<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -