I'm making a question that the number of elements in the vector are in 10 ^ 6 and just wanted to copy certain element to it only I did the normal but common way, is there another possibility if I make the copy faster? >
for(i = 0; i < teste; i++)
{
if(primo(vetor[i]))
{
aux[cont] = vetor[i];
cont++;
}
}
Algorithm to find the prime number
int primo(int num)
{
int pri = 1, i, raiz = sqrt(num);
if(num == 2)
{
return 1;
}
if (num == 1 || num == 0 || num % 2 == 0)
{
return 0;
}
for(i = 3; i <= raiz; i += 2)
{
if(num % i == 0)
{
pri = 0;
break;
}
}
return pri;
}