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
20<br>Calculate the kinette energy of a body the speed<br>that will be a mass tragm​
jolli1 [7]

Answer:

20

Explanation:

4 0
3 years ago
Write the definition of a function dashedline, with one parameter , an int . if the parameter is negative or zero, the function
GalinKa [24]
Static void DashedLine(int n){     if (n>1) Console.WriteLine(new String('-', n));}
5 0
3 years ago
Can someone please do a java computer science program for me? I’m desperate and I did not have enough time to learn the topic. I
vagabundo [1.1K]
Sure, how would you like me to send you the code?
5 0
3 years ago
Paavo was reviewing a request by an executive for a new subnotebook computer. The executive said that he wanted USB OTG support
grandymaker [24]

Answer:

Connecting a mobile device as a peripheral to an infected computer could allow malware to be sent to that device.

Explanation:

Since in the question it is mentioned that Paavo reviewed a request by an executive for subnotebook computer i.e new. but he needs to USB OTG support so it is a  USB i.e on the go that links the devices from one device to another

Therefore by links the mobile device to the computer i.e infected that allows malware we called virus so that we are able to send it to that device. By this,  he wants to tell about the USB OTG security

4 0
3 years ago
Explain how chord works. To increasing the fault tolerance in chord, each node maintains a successor list (finger table) instead
andrew11 [14]

Answer:

Chord is a set of rules for a peer-to-peer distributed hash table it collects key-value sets by allotting keys to several computers (known as "nodes"); a node will collect the values for all the keys for which that is reliable. Chord defines how keys are allocated to the nodes, and how a node can determine the value for a distributed key by first locating the node liable for such key.

Explanation:

A chord is a peer-to-peer lookup service. It Resolves the difficulty of establishing a data item in a combination of shared nodes, considering various node arrivals and removals The most crucial operation in most peer-to-peer method is the efficient position of data objects.

It is able of supporting only one operation i.e. given a key, it maps the key on a link.

Algorithm:

Algorithm shows working of the chord:

// x is a node used to find successor of id

x.find_successor(id)

if (id (x; successor])

return successor;

else

// query is being delivered around the circle

entrance successor.find_successor(id);

6 0
3 years ago
Other questions:
  • Write a function named shareALetter that takes one parameter, wordList – a list of words. Create and return a dictionary in whic
    13·1 answer
  • You must have an active ____ to test external links.
    5·1 answer
  • What font option will elevate part of the text to a higher level and decrease its size? A. Subscript
    8·1 answer
  • According to the Bureau of Labor Statistics, how
    14·1 answer
  • Which of the following statements is/are true by definition.
    5·1 answer
  • An element in an array is 4 bytes long and there are 10 elements in the array. How big is the array?
    6·2 answers
  • Which ORDER BY clause causes 10 rows to be retrieved from the result set, starting with the 20th row?
    5·1 answer
  • In a _____ network, each device on the network is attached to a central server. If the server fails, then the other devices will
    8·1 answer
  • Software applications called _____ provide the means to record information that passes through a computer or router that is hand
    10·1 answer
  • Can someone help me with this lab assignment? I really do not know what should I do?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!