#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
void prime_sieve(vector<int> p, int n)
{
//first mark all odd number's prime
p[2] = 1;
p[1] = p[0] = 0;
for (int i = 3; i <= n; i += 2)
{
p[i] = 1;
}
//sieve
for (ll i = 3; i <= n; i += 2)
{
//if the current number is not marked (it is prime)
if (p[i] == 1)
{
//mark all the multiples of i as not prime
for (ll j = i * i; j <= n; j = j + i)
{
p[j] = 0;
}
}
}
//special cases so e have to mention then individually
}
int main()
{
int n;
cin >> n;
vector<int> p(n + 1);
prime_sieve(p, n + 1);
for (int i = 0; i <= n; i++)
{
if (p[i] == 1)
cout << i << " ";
}
return 0;
}
I am unable to find why it is not giving any output. Any one up with the same issue?? My compiler is showing error somewhere in new_allocator.h file in this position
#endif
::operator delete(__p);
}
size_type
The error is exactly at that delete(__p). I am not understanding it why this error is happening
Aucun commentaire:
Enregistrer un commentaire