Hello, im having major problems getting my program to work. I have to list all the prime numbers from 1 to 1000. And I have to do this using a boolean vector. And i have to initialize all the numbers to true then go along and change them to false. Here's my code so far for the function that changes the true's to false's.
void TorF (vector<bool>& prime)
{
for (int current = 2; current < MAXSIZE; current++)
{
if (prime[current] = true)
{
for (int j = 2; j < MAXSIZE; current++)
{
if (current % j == 0)
prime[current] = false ;
}
}
}
}
...MAXSIZE = 1000
Yes i know this is very wrong. Do you have any pointers or tips for me...thanks alot
void TorF (vector<bool>& prime)
{
for (int current = 2; current < MAXSIZE; current++)
{
if (prime[current] = true)
{
for (int j = 2; j < MAXSIZE; current++)
{
if (current % j == 0)
prime[current] = false ;
}
}
}
}
...MAXSIZE = 1000
Yes i know this is very wrong. Do you have any pointers or tips for me...thanks alot