I need some help with a C++ arrays task. 2. Lights The park is illuminated by n (1


I need some help with a C++ arrays task.


2. Lights


The park is illuminated by n (1 <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="">


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 <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="">


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<br>RESULTS<br>EXPLANATIONS<br>1 10 101<br>FIRST NIGHT<br>6 2<br>0 10111<br>0 10111<br>110 10 1<br>THE NIGHT WHICH<br>SECOND NIGHT<br>SHINED MOST :<br>THE NIGHT WHICH<br>SHINED LEAST<br>1<br>9 5<br>0 1111010 1<br>0 10 100 0 0 0<br>01 111010 1 1ST NIGHT<br>1 100 10 10 1 2ND<br>01110 00 0 0 3RD<br>1 1011 1111 4TH<br>010 100 0 0 0 5TH<br>THE NIGHT WHICH<br>SHINED MOST<br>THE NIGHT WHICH<br>SHINED LEAST<br>

Extracted text: 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
Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here