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
s2008m [1.1K]
3 years ago
12

Consider this data sequence: "fish bird reptile reptile bird bird bird mammal fish". Let's define a SINGLETON to be a data eleme

nt that is not repeated immediately before or after itself in the sequence. So, here there are four SINGLETONs (the first appearance of "fish", the first appearance of "bird", "mammal", and the second appearance of "fish"). Write some code that uses a loop to read a sequence of words, terminated by the "xxxxx". The code assigns to the variable n the number of SINGLETONs that were read. (For example in the above data sequence it would assign 4 to n. Assume that n has already been declared. but not initialized. Assume that there will be at least one word before the terminating "xxxxx". ASSUME the availability of a variable, stdin, that references a Scanner object associated with standard input.

Social Studies
1 answer:
Gekata [30.6K]3 years ago
4 0

Answer:

// See attachment for full source code and output

// Program was implemented using C++ Programming Language

// Comments are used for explanatory purpose

#include<iostream>

using namespace std;

int main()

{

int n = 0; // Declare and initialise an integer variable n to 0

string prev ="xxxxx", current, next; // Declare string variables prev, current and next.

// At the same time initialise variable string to xxxxx

cin>>current; // Accept input for variable current

//If current is not equal to prev, the following statement in between the loop will be executed

// Else the program is terminated

while(current!=prev)

{

cin>>next; // accept input for variable next

if(prev != current && current != next)

{

n++; // Increment n by 1

}

prev = current; //store the value of current in previous

current = next; // store the value of next in current

cout<<prev<<endl; // Print previous string

cout<<current<<endl; // Print current string

cout<<next<<endl; // Print next string

}

return 0;

}

You might be interested in
What must the government do before a defendant stands trial for a crime? A) they must be indicted B) they must hire a lawyer C)
valina [46]

A.

Before a defendant stands trial, the Government must go to a grand jury and have the defendant indicted for the crime that they are accused of.

Grand juries serve as an important check on the Government's prosecution power by checking to see if there is probable cause for the indictment.

B-D all involve other important steps but A is the only one that the Government MUST do.

5 0
3 years ago
Read 2 more answers
What happens to a nation’s economy when they export more than they import and use economic terms please:)
Arturiano [62]

Answer:

When a nation exports more money they lose money.

Example:

If India exported 5 million dollars worth of cotton they lose 5 million dollars worth of cotton. 5 million dollars is not a lot for a nation's economy but I hope you understand!

3 0
3 years ago
People will not believe any message that contradicts their attitudes and existing opinions, unless the communicator introduces i
dimaraw [331]

Answer:

This concept is based on the psychological theory of  cognitive dissonance.

Explanation:

People try to remain in a state of cognitive consistency so that they can function mentally in the real world. Cognitive consistency happens when our beliefs and behaviors are in harmony. Cognitive dissonance, on the other hand, happens when we are introduced to knowledge that imbalances that harmony, that is, when we feel that our beliefs and attitudes are in conflict due to the new information we've received. When that takes place, we are driven to reduce the mental discomfort and restore balance. That can make us more likely to change our minds - having our beliefs questioned.

4 0
3 years ago
Which of the following is a career pathway for government and public administration?
Angelina_Jolie [31]

Answer:

B legal services

6 0
3 years ago
Which Government Bodies Influence National Fiscal Policies That Would Potentially Affect The Housing Market?
mariarad [96]
There are several government bodies that influence national fiscal policies that can affect the housing market, but by far the greatest impact comes from the legislative branch. 
5 0
3 years ago
Other questions:
  • Describe the racial ,ethnic,and gender make up of the far western frontier and the consequence of that make up
    12·1 answer
  • Should special tests be given to older adults in order to keep a driver's license?
    10·1 answer
  • Compared with wilhelm wundt, early behaviorists were much less likely to focus on the study of:
    15·1 answer
  • Jane's left hand movements are controlled by the right hemisphere in her brain. this is called:
    12·1 answer
  • Sheila came to your office about 8 months ago seeking counseling. She stated that she, "hoped to save her marriage." After a few
    14·1 answer
  • Explain how primary succession can lead to soil formation on a newly formed volcanic landscape
    11·1 answer
  • Which BEST completes the diagram?
    9·2 answers
  • John sold his 10 acre property to Susan and Matt. However, he retained his rights to the oil on the property. John retained what
    10·1 answer
  • If you are standing in the middle of a river and look at either side, you might see tall earthen hills. what are they and what d
    14·1 answer
  • WHAT IS HUMAN CAPITAL..???​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!