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
Mashutka [201]
3 years ago
8

Consider this data sequence: "fish bird reptile reptile bird bird bird mammal fish". There is a CONSECUTIVE REPETITION of length

3 (the three consecutive birds) and a CONSECUTIVE REPETITION of length 2 (the two reptiles). There are also several SINGLETONs of length 1 (a singleton fish, a singleton bird, a singleton mammal, and another singleton fish).Write some code that uses a loop to read in a sequence of words, terminated by the "xxxxx". The code assigns to t the number of CONSECUTIVE REPETITIONS that were read. (For example, in the above data sequence that value would be 2.) Assume that t has already been declared but not initialized . Assume that there will be at least one word before the terminating "xxxxx".
Computers and Technology
1 answer:
ioda3 years ago
8 0

Answer:

The code is given below. Follow the question and the code definitions for better understanding.

Explanation:

#include<iostream>

#include<string>

using namespace std;

int main(){

string pastWord="";

string currentWord,nextWord;

int n,t;

int singleton=0;

int consecutive=0;

cout<<"Enter words. ('xxxxx' to exit):\n";

cin>>nextWord;

do{

currentWord=nextWord;

cin>>nextWord;

if ( (currentWord!=pastWord)&&(currentWord!=nextWord) )

singleton++;

else if((currentWord==pastWord)&&(currentWord!=nextWord))

consecutive++;

pastWord=currentWord;

}while(nextWord!="xxxxx");

n=singleton;

t=consecutive;

cout<<"There were "<<n<<" singletons and "<<t<<" consecutive repetitions.";

cin.get();

return 0;

}

You might be interested in
A(n) _________________________ conveys a visual representation of data.
Komok [63]
I believe that the answer to fit this sentence is chart. Hope that this answer helped! ☺
3 0
3 years ago
1. You have a light in your living room that you can turn on or off from either (A) the living room, or (B) the kitchen.
Ksenya-84 [330]

Answer:

Table lamps or floor lamps with an adjustable head are the ideal fixtures for providing task lighting in living rooms.

Explanation:

3 0
2 years ago
Which practice enables recovery of accidental deletions in data records?
icang [17]
If it's on a document usually ctrl+z
5 0
3 years ago
Read 2 more answers
Users of an extranet can access a company or organization's entire intranet.
Vlad [161]
True............................I think
7 0
3 years ago
Read 2 more answers
5 programas más utilizados para realizar presentaciones electrónicas
Alchen [17]

Answer:

Google Slides

Microsoft PowerPoint

Visme

Prezi

Slidebean

3 0
3 years ago
Other questions:
  • On the first line, place your name in a comment. Create a program that does the following: Take in three integer numbers from th
    5·1 answer
  • PLEASE HELP ME!!!!
    12·2 answers
  • ________ gives its approval to U.S. e-commerce websites that follow strict privacy standards, such as explaining to visitors how
    6·1 answer
  • program students can get credit for their high school classes as long as they take a specific courses that a college will accept
    13·2 answers
  • Given the macro definition and global declarations shown in the image below, provide answers to the following questions:
    5·1 answer
  • Why are coders using encoder software? What are their advantages and disadvantages? And when might a coder need to use the codin
    12·1 answer
  • "________ are used to edit videos to enhance quality and appearance."
    6·1 answer
  • How are online sources used? Check all that apply.
    8·2 answers
  • Which of the following would be least effective?
    10·1 answer
  • What are the inputs that the model uses to make decisions?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!