answer.
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]
2 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]2 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
Our new catalog contains an eclectic collection of items
Cloud [144]

Answer: .

Explanation: .

7 0
2 years ago
Of 500 sessions that occurred on a website during a one-week period, 200 of them started on the homepage; 100 of these 200 sessi
Elena L [17]

Answer:

the homepage bounce rate

Explanation:

Bounce rate is defined as the percentage of people that visits a page on a website and then exit or leave. That is, the visitors did not view any other page except the first one and they just leave the page after that visit. In order to get the bounce rate, the total number of visitors to a single page is taken and its then divided by the total number of visits to the website. For example, if the total number of visitors to a website over a period of time is 3000, while those that only visited a page on the website is 500, then the bounce rate is

(500/3000) * 100 = 16%

For this question, the homepage recorded 100 visited only once out of 200 which means homepage bounce rate is 50% : (100/200)*100

While website bounce rate is total number of bounces across the website/total visit to the website

100+100 =200 this is the total bounces across the website

200/500 :500 is the total visit to the website

(200/500)*100 = 40 %

Therefore the homepage bounce rate is higher than the site bounce rate

7 0
2 years ago
After running the following pseudocode, what will the value of VARIABLE be? 1. Set value of VARIABLE to 5 2. Increase the value
Nutka1998 [239]

Answer:

10

Explanation:

you start with 5       5

you add 3                8

the variable is not odd so skip         8

the variable is even so add 1            9

the variable is odd so add 1              10

10

hope this helps <3

8 0
2 years ago
The population of town A is less than the population of town B. However, the population of town A is growing faster than the pop
defon

Answer:

#include<iostream>

using namespace std;

void main()

{

int townA_pop,townB_pop,count_years=1;

double rateA,rateB;

cout<<"please enter the population of town A"<<endl;

cin>>townA_pop;

cout<<"please enter the population of town B"<<endl;

cin>>townB_pop;

cout<<"please enter the grothw rate of town A"<<endl;

cin>>rateA;

cout<<"please enter the grothw rate of town B"<<endl;

cin>>rateB;

while(townA_pop < townB_pop)//IF town A pop is equal or greater than town B it will break

{

townA_pop = townA_pop +( townA_pop * (rateA /100) );

townB_pop = townB_pop +( townB_pop * (rateB /100) );

count_years++;

}

cout<<"after "<<count_years<<" of years the pop of town A will be graeter than or equal To the pop of town B"<<endl;

}

Explanation:

3 0
2 years ago
A small company has developed a specialized software product that it configures specially for each customer. New customers usual
egoroff_w [7]

Answer:

It would be good for the company to make the item open source since it lessens the progression costs and attempts.

If turned into open source then the code would be available to the customers and are they could to take off upgrades and modify it to their own specific needs. It reduces the company's efforts, satisfies the customers whilts including them.

6 0
2 years ago
Other questions:
  • Wesley has to create a web banner to announce a “Back to School” sale by an online retailer. Which information should he determi
    15·2 answers
  • For multicore processors to be used effectively, computers must understand how to divide tasks into parts that can be distribute
    6·1 answer
  • A firm that wanted to enable its employees to use and share data without allowing outsiders to gain access could do so by establ
    14·1 answer
  • Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and sec
    7·1 answer
  • LensForAll is a company that sells affordable contact lenses on its website. The CEO of the company realizes that an app must be
    9·1 answer
  • Doctors discovered a tumor in Amanda’s brain and used robotic surgery to remove it. Which best describes the role a worker in th
    15·2 answers
  • Which of the following image file formats uses lossy file compression?
    7·1 answer
  • Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest
    13·2 answers
  • Write a method that will receive 2 numbers as parameters and will return a string containing the pattern based on those two numb
    10·1 answer
  • How do many corporations most likely manage the health and safety of their employees and the workplace?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!