#include <stdio.h>
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <iomanip>
#include <string.h>
#define MAXN 1005
Using Std::cin;
Using Std::cout;
int a[maxn];//array a[] is defined to be placed in the global position, and then in the main function of the assignment operation, otherwise it will be an error
int main () {
memset (A, 0, sizeof (a));
int N, k, first = 1;
cout << "Please enter numbers:" << Std::endl;
Cin >> k >> N;
if (k <= n && n << 1000) {
for (int i = 1; I <= K; i++) {//per person operation once, so outer loop is human
for (int j = 1; J <= N; j + +) {//each lamp is to be operated by each person once, so the inner loop is human
if (j%i = = 0)
A[J] =!a[j];//very interesting place
for (int m = 0; M <= N; m++) {
if (A[m]) {
If first is 0;//here to avoid unnecessary output of the initial element
else cout << m << Std::endl;
}
}
}
}
}
Else
cout << "Wrong number" << Std::endl;
}
Turn on the lights (Algorithmic Race Primer Classic)