ome help with a C++ arrays task. Provide the working code and make explanations using // . The initial code is provided in the photograph. The park is illuminated by n (1
I need some help with a C++ arrays task. Provide the working code and make explanations using // . The initial code is provided in the photograph.
The park is illuminated by n (1 <n <100) lights. Each of them shines all night or not. Of course, which lights were on the first night and which were not. Every other night the condition of the lamps shall be determined by the following rules:
* The lamp will not illuminate if both of its neighbors were lit last night;
* The lamp shall illuminate if one of its neighbors was illuminated last night and the other was not;
** if neither of the first two rules applies to the lamp, it will illuminate when the night is even and will not illuminate when the night is odd.
Make a
The first line of the original data file contains two integers: the number of lights n and the number of nights k. The second line contains a sequence of zeros and units separated by a space. This is the state of each lamp: a unit means that the lamp was lit on the first night, and zero means that it was not lit.
Step by step
Solved in 2 steps