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]
2 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]2 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
There are 2048bytes in4megabytes true or false​
ollegr [7]

Answer:

Explanation:

bonjour,

1 MB =  1 000 000 B (bytes)

4 MB = 4 000 000B

=> false

5 0
2 years ago
Java what are synchronized functions.
adelina 88 [10]

<h2>answer:</h2>

Synchronized method is used to lock an object for any shared resource. When a thread invokes a synchronized method, it automatically acquires the lock for that object and releases it when the thread completes its task.','.

4 0
3 years ago
Assume the int variables i, lo, hi, and result have been declared and that lo and hi have been initialized. Write a for loop tha
IRISSAK [1]

Answer:

result=0;

for (i=lo ; i<=hi; i++){

result += i;

}

Explanation:

The question says result was declared but not initialized, so using result without initializing it to 0 would throw an error as result would be undefined and you can't add a number to undefined

Another way to do it to keep everything inside the loop would be

for (i=lo ; i<=hi; i++){

if (i==lo) result= 0;

result += i;

}

but this is impractical since it would add unnecesary operations in each cycle of the loop

4 0
3 years ago
Average LCD panels are around _______________, which most monitor authorities consider excellent brightness.
uysha [10]

Answer:

The correct answer to the following question will be option D. 300 nits.

Explanation:

LCD Monitors: LCD stands for Liquid Crystal Display, the display which uses two sheets of liquid crystal with polarizing material between the sheets and also known as Flat panel monitor.

  • Each of the crystal in LCD's is like a shutter, it either allows to pass the light or it blocks the light. There is a fixed type of resolution in LCD
  • LCD panels can be easily moved around all, lightweight, compact and small in size.
  • An average 17-inch LCD monitor could be around 15 pounds, upwards 300 nits which gives the perfect brightness.

So, Option D is the correct answer.

3 0
3 years ago
For a Know Simple query, a Fully Meets rating can be given if the result does not display the answer, but it is at the very top
tekilochka [14]

Answer:

For a Know Simple query, a Fully Meets rating can be given if the result does not display the answer, but it is at the very top of the landing page.

B) False

Explanation:

  • A know simple query is special form of a know query. The query which are intended to know something like what is the length of pitch of a cricket ground?
  • A know simple query is such a know query that can be described in very little amount of words.
  • A know simple query would only get the fully meet ratings if the result shown has the result in a special result block or it is shown upfront. You don't need to open a link to get the answer in such scenario.

6 0
3 years ago
Other questions:
  • Which network component connects a device with the transmission media and allows it to send?
    7·1 answer
  • What can a dimm use to hold data and amplify a signal just before the data is written to the module?
    12·1 answer
  • According to which virtue do you need to secure information by limiting computer access to authorized personnel only ?
    13·2 answers
  • What is the impact of information technology in your daily life?
    12·1 answer
  • Assume you're using a three-button mouse. To access shortcut menus, you would
    9·1 answer
  • . Two blue armies are each poised on opposite hills preparing to attack a single red army in the valley. The red army can defeat
    5·1 answer
  • How do you think weather can affect sailing?<br><br>What would be good sailing weather?​
    9·1 answer
  • Write a Java program that launches 1000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum
    11·1 answer
  • When should you stop where you are, drop to the
    11·1 answer
  • Which of the following are vector graphic file formats? Choose all that apply.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!