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
cupoosta [38]
3 years ago
5

Write a program that reads a list of integers into a vector, and outputs the two smallest integers in the list, in ascending ord

er. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 and 3 You can assume that the list of integers will have at least 2 values. To achieve the above, first read the integers into a vector. Hint: Make sure to initialize the second smallest and smallest integers properly. Submit your .cpp code with this question's link. Output runs are not required.
Computers and Technology
1 answer:
AnnyKZ [126]3 years ago
8 0

Answer:

In C++:

#include <bits/stdc++.h>

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<int> vectItems;

cout << "Vector length: ";

int ln; cin>>ln;

int num;

for (int ikk = 0; ikk < ln; ikk++){

 cin >> num;

 vectItems.push_back(num);}

int small, secsmall;

small = secsmall = INT_MAX;  

for (int ikk = 0; ikk < ln; ikk++){

 if(vectItems[ikk] < small){

     secsmall = small;  

           small = vectItems[ikk];   }

 else if (vectItems[ikk] < secsmall && vectItems[ikk] != small) {

           secsmall = vectItems[ikk];} }

 cout<<small<<" "<<secsmall;

 return 0;}

Explanation:

See attachment for program file where comments are used for explanation

Download cpp
You might be interested in
PLEASE HELP ASAP
Alex73 [517]
I dont know if you need more people to answer so.. my mom, dad, brother, best friend 1, best friend 2, grandma, grandpa, cousin, aunt, uncle
7 0
3 years ago
Read 2 more answers
Write a for loop that iterates from 1 to numbersamples to double any element's value in datasamples that is less than minvalue.
CaHeK987 [17]

Answer:

function dataSamples=AdjustMinValue(numberSamples, userSamples, minValue)

dataSamples=userSamples;

%for loop

for i=1:numberSamples

%checking if dataSamples value at index,i

%is less than minValue

if dataSamples(i)<minValue

%set double of dataSamples value

dataSamples(i)= 2*dataSamples(i);

end

end

end

Explanation:

The given code is in MATLAB.

4 0
3 years ago
1) what are two functions of a pick or count condition?
viktelen [127]
1.  The best option is C) pick an object at random, and keep track of how many copies of an object are left in a game.
2.   The best option is D) clockwise and counterclockwise.
3.    your 3rd question does not seem to be clear to me.
3 0
3 years ago
________ can contain stacked images, text, and other elements which collectively comprise a Photoshop file.
emmasim [6.3K]
If you don’t mind can u add the picture it helps me Answer the question better
6 0
2 years ago
Can be referred to as a universal network of interrelated computers which delivers a very wide variety of information and commun
nlexa [21]

Answer:

Internet

Explanation:

just took the test and got A

7 0
3 years ago
Other questions:
  • To gain one pound of fat, how many extra calories would you need to consume?
    12·1 answer
  • The part of the poppet valve that contacts the valve seat is called the A. face. B. margin. C. head. D. stem.
    6·2 answers
  • A virus is a self-replicating program that produces its own code by attaching copies of it into other executable codes.
    7·1 answer
  • Which of the following feature are parts of Toyota’s safety system?
    10·1 answer
  • Which is said to be ‘computer on a chip’ (a) Micro processors (b) Microcontrollers (c) Both (c) None of the above
    9·1 answer
  • Which of the following is a valid c++ identifier a. mouse b. _int c. 2_stop d. float​
    10·1 answer
  • Consider the method get Hours, which is intended to calculate the number of hours that a vehicle takes to travel between two mil
    6·1 answer
  • Please help me please please
    14·2 answers
  • Which of the following makes Super Mario Run unique?
    6·1 answer
  • Given a list of syntax errors from a compiler, a programmer should focus attention on which error(s), before recompiling?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!