I need some help with a C++ arrays task. (Please make it work as like image provded!)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
Transcribed Image 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
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY