I need some help with a C++ arrays task. (Please make it work as like image provded!)
I need some help with a C++ arrays task. (Please make it work as like image provded!)
2. Lights
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 program to determine which lights are on and which will not be lit when k (1 <k <100) nights have elapsed, and to find which night the most lights were lit and which the least. If there are several identical nights with the most or least lights lit, the night with the lower number must be indicated.
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.
![INITIAL DATA
RESULTS
EXPLANATIONS
1 10 101
FIRST NIGHT
6 2
0 10111
0 10111
110 10 1
THE NIGHT WHICH
SECOND NIGHT
SHINED MOST :
THE NIGHT WHICH
SHINED LEAST
1
9 5
0 1111010 1
0 10 100 0 0 0
01 111010 1 1ST NIGHT
1 100 10 10 1 2ND
01110 00 0 0 3RD
1 1011 1111 4TH
010 100 0 0 0 5TH
THE NIGHT WHICH
SHINED MOST
THE NIGHT WHICH
SHINED LEAST](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbf933da8-c5dc-476e-99b6-31fa41e1d7aa%2F1a965c86-0b98-48b2-8a2b-847a12c791bb%2F28pe4q4_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 5 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)