C++, Learning, Basic Return Primes

  boolean, c++, primes

My goal is that: the program return the list of numbers in the vector i made, which are the primes numbers, the code is wrong,

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

vector < int > L;
bool mark[10];
void colador()
{
    fill(mark,mark+10, false);
    for(int i=2; i*i <=10; i++)
    {
        if(!mark[i])
        {
            L.push_back(i); 
            for(int j=i*i; j<=10; j+=i)
            {
                mark[j]=true;
            }
        }
    }
    for(int e=sqrt(10)+1; e<=10; e++)
    {
        if(!mark[e])
        {
            L.push_back(e);
        }
    }
}



int main()
{
    for( int i=0; i<=9; i++)
    {
        cout << L[i] << endl ;
    }
    return 0;
}

When i compile it, the program doesn’t show me anything. What’s wrong?

Source: Windows Questions C++

LEAVE A COMMENT