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
nlexa [21]
3 years ago
13

Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative numbe

r is not a part of the sorted list). Assume the number of integers is always odd.
Ex: If the input is: 2 3 4 8 11 -1
the output is:
Middle item: 4
The maximum number of inputs for any test case should not exceed 9. If exceeded, output "Too many numbers". Hint: First read the data into a vector. Then, based on the number of items, find the middle item. 276452.1593070
(Must include vector library to use vectors)
Computers and Technology
1 answer:
7nadin3 [17]3 years ago
5 0

Answer:

If the input is: 2 3 4 8 11 -1

the output is:

Middle item: 4

To explain the given is as follows,

Explanation:

Code:-

#include <iostream>

#include <vector>

using namespace std;

int main()

{

   std::vector<int> v;

   int temp, i=0;

   cout <<"Enter the sorted elements "<<endl;

   while(1){

        cout<<"Enter ["<<i<<"]element"<<endl;//Accept elements in a vector

        cin >> temp;

        i++;

        if(temp>0)

          v.push_back(temp);

        else       //If negative number is inputed assume end of input

          break;

   }

   cout<<"Size of a vector is:"<<v.size()<<endl; //Find size of vector

   

 

   if (v.size() % 2 == 0){

       cout <<"NUMBER OF ELEMENTS SHOULD BE ODD";

   }

   else if(v.size()>9){

       cout<<"Too many numbers.";

   }

   else{

       cout<<"Median = " << v[v.size()/2]<<endl; //Find median  

   }

       

}

Output:

You might be interested in
FTP is commonly used to __________ and __________ files to a server.
Aleks [24]

Answer:

upload; download

Explanation:

FTP (File Transfer Protocol) is an internet protocol used to upload and download a file to a server, there are some programs help us to transfer this data to a server, in some cases, we're going to need these programs to upload website files to the server like images or videos, or some websites where do you need a user and passwords to upload file by FTP

8 0
4 years ago
The term _____ best describes the level of technology skills needed in today’s business world.
laiz [17]
The answer is fluency.
4 0
3 years ago
Identify the variables listed below as either quantitative (discrete or continuous) or categorical (nominal or ordinal):
Akimi4 [234]

Answer:

Quantitative: Age, heart rate, number of pets, salary

 <em>discrete</em>: number of pets

 <em>continuous</em>: Age, heart rate, salary

Categorical: Gender, eye color, metal rankings

<em>Nominal:</em> Gender, eye color

<em>Ordinal:</em> metal rankings

Explanation:

Quantitative are those variables which are for quantity or number with units for measurement.

Categorical are qualitative variable which can be categorized or grouped in different groups or it may be ranking scales

5 0
3 years ago
What are the main advantages of a solid-state drive (SSD) over a conventional hard disk drive (HDD)? (Choose three)
Masja [62]

Answer:

The benefits of SSDs over HDDs include:

Faster read/write speeds. SSDs can access large files quickly.

Quicker boot times and better performance. Because the drive does not need to spin up as an HDD would, it is more responsive and provides better load performance.

Durability. ...

Power consumption. ...

Quieter. ...

Size.

Explanation:

4 0
3 years ago
"someone has tampered with your computer and erased data". what kind of computer threat is this
pishuonlain [190]
<span>So if some access your computer and erased some data without your permission or knowing then this threat is called as security threat. So you should have these stand alone systems with username and password concept that would protect your sensitive and private data and have the control over your computer.</span>
4 0
3 years ago
Other questions:
  • Identify the six components of an information system. Which are most directly affected by the study of computer security? Which
    8·1 answer
  • Write a program that unpickle's employee dictionary and while reading from the dictionary, it allows users to lookup an employee
    9·1 answer
  • TWO MINUTES LEFT<br> ________ __________ is the physical arrangement of devices on a network.
    9·1 answer
  • Which of the following is an advantage of using
    6·2 answers
  • Choose the best type of loop for each situation.
    6·1 answer
  • What will the following code display? int numbers[4] = { 99, 87 }; cout &lt;&lt; numbers[3] &lt;&lt; endl; a. 87 b.0 d. 34. What
    12·1 answer
  • What is the effects of computer and internet attacks​
    11·2 answers
  • Ajdbksjdnksnsd helppp​
    11·1 answer
  • Programming Cycle. Arrange them in correct order​
    5·2 answers
  • Why does my laptop keep disconnecting from the wifi.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!