#include<iostream.h>
int N;
template<class T>
class SeqList
{
private:
int *data; //存储数组的初地址
int length; //线性表的长度
public:
SeqList(int I)
~SeqList() {}
void Delete(int n);
void SkipDel();
void PrintSL();
};
SeqList::SeqList(int I)
{ length=l+1;
data=new int[length];
for(int i=2;i<length;i++)
data[i]=1;
}
SeqList::~SeqList()
{
delete [] data;
}
void SeqList::Delete(int n)
{
data[n]=0;
}
void SeqList::SkipDel()
{
for(int i1=2;i1<length;i1++)
if(data[i1])
for(int i2=2;i1*i2<length;i2++)
Delete(i1*i2);
}
void SeqList::PrintSL()
{
for(int i=0;i<length;i++)
if(data[i]==1)
cout<<" "<<i;
cout<<endl;
}
void main()
{
cout<<"输入范围值N:";
cin>>N;
SeqList A(N);
A.SkipDel();
cout<<"2~"<<N<<"的素数有:";
A.PrintSL();
}