teacher_code_c/test2.cpp

34 lines
445 B
C++

#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int shuzu[2000] = {0,0};
for (int i = 2; i <=n; i++)
{
shuzu[1]=0;
}
for (int i = 2 ;i < n-1; i++)
{
int num = i+1;
int b = i;
while (shuzu[num]==0)
{
num++;
}
for (int j = num; j <=n; j++) {
if (j%b==0)
{
shuzu[j] = 0;
}
}
}
for (int i = 1; i < n; i++)
{
cout << i << " " << shuzu[i] << endl;
}
return 0;
}