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
Attributes of a website indicates a more reliable source of information
Blababa [14]
If it is a government website with the .gov url it is more reliable.
6 0
3 years ago
Why are websites operated by recognized print publishers, such as newspapers and journals, generally accurate and reliable?
leonid [27]
I think the correct answer would be that the <span>contents has usually been reviewed and edited by experts. These websites are required to do as such since it is how they make money from it. And if information are erroneous, it would make a big problem. Hope this helps.</span>
8 0
4 years ago
Read 2 more answers
13. A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails".
serious [3.7K]

Answer: c

Explanation:

only reasonable answer

7 0
3 years ago
Mr chen xi is a vedio maker in singapore . He had created 14GB vedio file for his customer is united states . Name and describe
Kipish [7]

Answer:

Google Drive

Explanation:

It is best he uses the Google Drive to shredded the video with his customers. He may choose to compress the file first using winZip, 7zip or zip softwares. The steps are highlighted below:

-On your computer, go to drive.google.com.

-Open or create a folder.

-To upload files and folders, drag them into the Google Drive folder.

-Share the link to your drive.

(...and remember to share password if folder is encrypted).

Cheers.

7 0
3 years ago
What is the overall objective of an IT risk assessment? To assist IT management in establishing a budget for countermeasures To
QveST [7]
The overall objective of an IT risk assessment is to assist an organization in identifying risks and impacts.<span> The process includes discovering, correcting and preventing security problems.</span>
The IT risk assessment document identifies threats, estimates risks and determines how to manage them.
4 0
3 years ago
Other questions:
  • When formatting documents, ____ settings determine where text begins on a line in relation to the left margin?
    8·1 answer
  • Why is it important to consider the readability of a Web page when selecting and applying a background color?
    12·1 answer
  • Apart from confidential information, what other information does NDA help to outline?
    15·1 answer
  • Acomputer with a domain name is called a
    8·1 answer
  • I need help plz it keeps on happening and idk what to do
    12·1 answer
  • 4.2 Code Practice: Question 1
    14·1 answer
  • What does a shutter speed of one mean?
    14·2 answers
  • Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
    13·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    13·2 answers
  • What's a checked exception?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!