利用顺序表编写素数,用c++
我是菜鸟,谁能告诉我后面怎么编写,还有前面也不知道对不对,谢谢了#include <iostream.h>
class SeqList
{
private:
int MaxSize;
int length;
T *data;
public:
SeqList( ) ;
SeqList(int n ) ;
SeqList(T a[ ], int n,int m);
~SeqList( ) ;
void PrintList()
void Delete(int i);
void ScanDelete();
};
SeqList::SeqList(int n )
{
data=new int[n+1];
for(i=2;i<=n;i++)
data[i]=1;
length=n+1
}
void SeqList::Delete(int i)
{
j=i+i;
while (j<=length)
{
data[j]=0; j+=i;
}
}
void SeqList:: ScanDelete()
{
for(i=2;i<length;i++)
if(data[i]==1)
Delete(i);
}
void SeqList:: PrintList()
{
for(i=2;i<=length;i++)
if (data[i])
cout<<" "<<i;
}