Use vector template

xiaoxiao2021-03-06  71

#include

#include <

Vector>

#include

Using

Namespace

STD;

Int main

Int Argc,

Char * argv []) {

IF (argc! = 2) {

CERR <<

"USAGE: / N / T" << argv [0] <<

"" << ENDL;

Return 1;

}

INT count = 0;

//Calculate

unsigned

INT MAXNUM = ATOI (Argv [1]);

Vector <

unsigned

int> primelist;

Vector <

unsigned

Int> :: item N;

// Vector internal pointer

Primelist.push_back (2);

// Put 2

unsigned

INT A = 2;

FOR (; a <0xffffffffffffff; A ) {

unsigned

INT B = SQRT (a);

// Compare the opening value to determine

For (n = primelist.begin (); 1; n ) {

// Traverse the number of pixels

IF (* n> b)

Break;

IF ((a% * n) == 0)

Goto endfor;

}

Primelist.push_back (a);

IF (a <= maxnum) {

COUNT ;

Cout << a <<

""

}

Else

Break;

ENDFOR :;

}

COUT << Endl << count << Endl <<

"* End *" << ENDL;

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-109490.html

New Post(0)