IDNLearn.com: Your destination for reliable and timely answers to any question. Discover comprehensive answers from knowledgeable members of our community, covering a wide range of topics to meet all your informational needs.
Sagot :
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
Thank you for using this platform to share and learn. Don't hesitate to keep asking and answering. We value every contribution you make. Thank you for choosing IDNLearn.com. We’re here to provide reliable answers, so please visit us again for more solutions.