Question: Write a program reading integers until zero is entered and printing the length of the longest sequence of consecutive numbers of the same value

 

Write a program reading integers until zero is entered and printing the

Write a program reading integers until zero is entered and printing the length of the longest sequence of consecutive numbers of the same value (and this value). For example, for 2 2 2 2 3 3 3 2 6 6 60 the result should be for Longest sequence: 4 times 2 2 2 2 3 3 3 3 3 2 6 6 6 0 the result should be Longest sequence: 5 times 3 and for 2 2 333 333 2 3 -66-66-66 0 it should be Longest sequence: 3 times -66 Do not use arrays, strings or any other kind of collections. Check your solutions for different cases: when the longest sequence is at the beginning, somewhere in the middle, or at the very end.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!