Wpis z mikrobloga

Może ktoś zerknąć? Bez funkcji free działa:(
#jezykc
printf("\nPodaj liczba naturalna\n");
int a = 0;
scanf_s("%d", &a);
int *Zbior;
Zbior = (int*)malloc(a*sizeof(int));

for (int i = 0; i <= a; i++)
{
Zbior[i] = 1;
}
for (int i = 2; i <= sqrt(a); i++)
{
if (Zbior[i] == 1)
{
int j = i;
while (j <= a)
{
Zbior[j] = 0;
j = j + i;
}
}
}

if (Zbior[a] == 1)
printf("Liczba %d jest liczba pierwsza", a);
else
printf("Liczba %d nie jest liczba pierwsza", a);

free(Zbior);
  • 8
Cały kod:
#include
#include
#include
#include

int main()
{
do
{

printf("\nPodaj liczba naturalna\n");
int a = 0;
scanf_s("%d", &a);
double max = sqrt(a);
bool *Zbior;
Zbior = (bool*)malloc(a*sizeof(*Zbior));

for (int i = 0; i <= a; i++)
{
Zbior[i] = true;
}
for (int i = 2; i <= max; i++)
{
if (Zbior[i] == true)
{
int j = i;
while (j <= a)
{
Zbior[j] = false;
j =