c++判断2-100的数是否为素数,如果不为素数,则把它分解为素数之积,并输出

来源:百度知道 编辑:UC知道 时间:2024/09/20 06:45:26
RT
求高人解答

//---------------------------------------------------------------------------
#include <iostream>
#include <vector>

using namespace std;
class ss{
int ing[99];
public:
vector<int> hs;

void fjhs(void)
{
vector<int>::iterator begin=hs.begin();
const vector<int>::iterator end=hs.end();
while (begin!=end)
{
int p=*begin;
cout<<p<<"="<<flush;
for (int i=2; i<=p;) {

if (p%i==0) {
if (p!=*begin) cout<<'*'<<flush;
cout<<i;
p/=i;
}
else if (p%i) {
++i;
}
}
cout<<endl;
++begin;
}
}

ss()
{
for (int i=0; i<99; i++) {
ing[i]=i+2;
}
}
void fj(void)
{

for (int i=2; i