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
What is the difference between 1080p and 2k?
professor190 [17]
They have the same  vertical resolution. I can suggest you to watch the video in youtube .<span>https://www.youtube.com/watch?v=uluEEGBHyUE</span>
7 0
3 years ago
The rules of a programming language constitute its__________________
kogti [31]
The rules of a programming language constitute its syntax.
7 0
2 years ago
Have you ever tried using such a camera?​
guapka [62]

Answer: yeah i mean i use my canon camera

Explanation:

7 0
2 years ago
Why is audio greyed out on powerpoint ms office 2011?
-BARSIC- [3]
Because its a old type of software and probably wont run on your computer
7 0
3 years ago
Which U.S. government agency first funded the development of the Internet?
Doss [256]

Answer: ARPANET

Explanation: The first workable prototype of the Internet came in the late 1960s with the creation of ARPANET, or the Advanced Research Projects Agency Network. Originally funded by the U.S. Department of Defense, ARPANET used packet switching to allow multiple computers to communicate on a single network.

7 0
3 years ago
Read 2 more answers
Other questions:
  • The number of credits awarded for the CLEP exam is determined by__<br> Help pls!
    15·1 answer
  • Insert a function in cell g5 to calculate the first student's monthly payment, using appropriate relative and absolute cell refe
    13·1 answer
  • The most complex part of ssl is the ___________ protocol.
    7·2 answers
  • What is the output of the following program?
    10·1 answer
  • A domain name is used to: *
    15·1 answer
  • Pls help me<br> first one to answer correctly gets brainly points
    6·2 answers
  • ______________ is a raw fact about a person or an object
    6·1 answer
  • What are some good digital habits?
    5·2 answers
  • Only need help on f and correct me if im wrong for the other questions please
    11·1 answer
  • The most important preinstalled software is the ______ software that allows you to use the computer the first time you turn it o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!