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
Studentka2010 [4]
3 years ago
7

Write a program second.cpp that takes in a sequence of integers, and prints the second largest number and the second smallest nu

mber. Note that in the case of repeated numbers, we really mean the second largest and smallest out of the distinct numbers (as seen in the examples below). You may only use the headers: and .
Computers and Technology
1 answer:
sergey [27]3 years ago
4 0

Answer:

The program is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   int n;

   cout<<"Elements: ";

   cin>>n;

   vector <int>vectnum;

   int numInp;

   for (int i = 1; i <= n; i++){        cin>>numInp;        vectnum.push_back(numInp);    }

   int big, secbig;

   big = vectnum.at(0);      secbig = vectnum.at(1);

   if(vectnum.at(0)<vectnum.at(1)){     big = vectnum.at(1);  secbig = vectnum.at(0);   }

   for (int i = 2; i< n ; i ++) {

     if (vectnum.at(i) > big) {

        secbig = big;;

        big = vectnum.at(i);

     }

     else if (vectnum.at(i) > secbig && vectnum.at(i) != big) {

        secbig = vectnum.at(i);

     }

  }

  cout<<"Second Largest: "<<secbig<<endl;

  int small, secsmall;

  small = vectnum.at(1);       secsmall = vectnum.at(0);

  if(vectnum.at(0)<vectnum.at(1)){ small = vectnum.at(0);  secsmall = vectnum.at(1);   }

  for(int i=0; i<n; i++) {

     if(small>vectnum.at(i)) {  

        secsmall = small;

        small = vectnum.at(i);      }

     else if(vectnum.at(i) < secsmall){

        secsmall = vectnum.at(i);      }   }

  cout<<"Second Smallest: "<<secsmall;

  return 0;

}

Explanation:

See attachment for explanation

Download cpp
You might be interested in
Sentiment analysis algorithms use simple terms to express sentiment about a product or service, so ________ makes it __________
Anna35 [415]

Answer:

sarcasm , difficult

Explanation:

Sarcasm make it difficult to classify online content as positive ,negative or neutral because sarcasm content had many meaning and it involve some humor also which make it difficult weather to classify as positive or negative or neutral.

5 0
3 years ago
While approaching your parked car, the first step before getting in should be
Lady_Fox [76]

The answer to your question is:

A. Have the key in your hand.

8 0
3 years ago
Read 2 more answers
A _______ is used to present data in a simplified, graphical format that allows your audience to read less text while still bein
steposvetlana [31]
Your correct answer would be Legend.


answer choice is B.
3 0
3 years ago
Read 2 more answers
( Game Design) The companies who get video games out to consumers are called:
Bad White [126]

Answer:

They are called video game publishers

Explanation:

A video game publisher is responsible for financing a video game’s development, marketing, and release of the game to the consumers. Basically, they are the ones who manage the business end of the gaming field. If the video game company is well established, the publishers of that company will be the ones to distribute while some smaller companies will hire distribution companies to distribute the games for them

3 0
3 years ago
We noted that network layer functionality can be broadly divided into data plane functionality and control plane functionality.
Lisa [10]

Answer:

A data plane is used in a network, it is also known as forwarding plane. The main responsibility of a data plane is to carry forward the packets or data between different clients of the network. • A control plane used in the network is responsible for establishing connection information. That is a control plane connects different clients by exchanging their routing and forwarding information.  

Comment  

• A control plane makes decisions about how a packet can be carry forwarded in the network. It uses different protocols and makes the routers and switches to exchange their routing information with the next router or switch. This information could be the routing tables containing which is the shortest path to reach the next router. • The control plane also configures and manages the network components. • The data plane uses the instructions and commands passed by the control plane to forward the data packets. Data plane uses the forwarding table of control plane and transfers data from one client to another client.  

• Thus decisions made by control plane are used by data plane to manage the network traffic and to transfer the data.  

Explanation:

3 0
3 years ago
Other questions:
  • Why is the rate of increasing performance slowing down? Please help
    8·1 answer
  • Why would you use a database system instead of traditional file system
    6·1 answer
  • A child with suspected sleep apnea was given an apnea monitoring device to use over the next month. The device was capable of re
    6·1 answer
  • When communicating with a server on another subnet, which of the following settings is used to determine which direction it need
    6·1 answer
  • To remove any hidden data from your document before sharing it you should:
    8·2 answers
  • A device that allows multiple computers to communicate with each other is
    9·1 answer
  • ......... defines the path of the movement for an object.
    12·1 answer
  • Write an algorithm (pseudo-code) that takes an unsorted list of n integers and outputs a sorted list of all duplicate integers.
    6·1 answer
  • Which keys can be pressed to change the cuboid/frame selector color on remotasks lidar course
    6·1 answer
  • What is the difference between cyberbullying and bullying.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!