С++. Необходимо найти n-ое простое число. часть кода есть, но нужно дописать

сам код:

#include iostream

#include vector


int main()

{

int num, k, arr_cap = 1500000, counter = 0, i;

std::cin >> k;

std::vector main_arr(arr_cap, 1);

main_arr[1] = main_arr[2] = 0;

while(counter < k)

{

for(i = 2; i < k; i++)

{

if (!main_arr[i] || i * 1ll * i > k)

continue;

}

counter++;

for (int j = i * i; j <= k; j += i)

main_arr[j] = 0;


}



}
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.