1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alinara [238K]
3 years ago
7

python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i

s considered a CONSECUTIVE DUPLICATE. In this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. Note that the last 3 is not a consecutive duplicate because it was preceded by a 7. Write some code that uses a loop to read such a sequence of non-negative integers, terminated by a negative number. When the code finishes executing, the number of consecutive duplicates encountered is printed. In this case,3 would be printed. ASSUME the availability of a variable, stdin, that references a Scanner object associated with standard input.
Computers and Technology
1 answer:
Vika [28.1K]3 years ago
7 0

int firstNumber,secondNumber = -1, duplicates = 0;

do {

cin >> firstNumber;

if ( secondNumber == -1) {

secondNumber = firstNumber;

}else {

if ( secondNumber == firstNumber )

duplicates++;

else

secondNumber = firstNumber;

}

} while(firstNumber > 0 );

cout << duplicates;

You might be interested in
The term ____ is a technical term for the region of memory that holds data waiting to be transferred from one device to another.
shutvik [7]
<span>buffer is what your looking for    my friend made this  it should help  https://quizlet.com/20507517/ch-4-operating-systems-and-file-management-flash-cards/</span>

8 0
3 years ago
The CPU converts into information. The CPU is the mastermind of the computer, controlling everything that goes on through a seri
Harman [31]

Answer:

Mathematical sequences

Explanation:

Just did it

5 0
2 years ago
Read 2 more answers
Why doesn't the ad load ?
baherus [9]
Try refreshing the page, if not restart your device check your internet etc.
3 0
2 years ago
Read 2 more answers
Consider the following code:
Phoenix [80]

Answer:

customers += newCustomer;

Explanation:

The operator += expands into + and assignment. The assignment is not overloaded so the required code is

customers += newCustomer;

This expands into

customers = customers + newCustomer;

The overloaded + operator is called for the right expression. This returns a `CustomerList`, which is then assigned through the = operator to `customers`.

3 0
2 years ago
Why doesnt brainly let me skip by watching video?
oksian1 [2.3K]

What do you want to skip in brainly? There isn't anything to skip that I can think of.

4 0
3 years ago
Other questions:
  • What does intergrated organization mean
    15·1 answer
  • Provide the definition for each of the following structures and unions:
    8·1 answer
  • What quantities are measured by the following sensors:
    9·1 answer
  • Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
    15·1 answer
  • Provide a few examples of how cryptography actually secures data.
    8·1 answer
  • GIVING BRAINLIST TO WHOEVER ANSWERS
    9·1 answer
  • The graph shows households in the world with internet access from 2003 to 2019. A graph titled Percentage of Households with Int
    6·2 answers
  • create a function that draws a certain number of spaces, followed by a certain number of stars, followed by a newline.
    6·1 answer
  • A signal has a wavelength of 1 11m in air. How far can the front of the wave travel during 1000 periods?
    7·1 answer
  • Help me please. I dont really understand this.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!