Welcome to Westonci.ca, where your questions are met with accurate answers from a community of experts and enthusiasts. Our platform connects you with professionals ready to provide precise answers to all your questions in various areas of expertise. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
#include
#include
using namespace std;
int main(){
int input[] = {-19, 34, -54, 65, -1};
std::vector voutput:
std::vector vinput (input, input + sizeof(input) / sizeof(int) );
for (std::vector::iterator it = vinput.begin(); it != vinput.end(); ++it)
if(*it > 0) voutput.insert(voutput.begin(), *it);
for(std::vector::iterator it = voutput.begin(); it < voutput.end(); ++it)
std::cout << *it << ‘\n’ ;
return 0;
}
#include
using namespace std;
int main(){
int input[] = {-19, 34, -54, 65, -1};
std::vector voutput:
std::vector vinput (input, input + sizeof(input) / sizeof(int) );
for (std::vector::iterator it = vinput.begin(); it != vinput.end(); ++it)
if(*it > 0) voutput.insert(voutput.begin(), *it);
for(std::vector::iterator it = voutput.begin(); it < voutput.end(); ++it)
std::cout << *it << ‘\n’ ;
return 0;
}
The program is an illustration of vectors; vectors are data structures that are used to hold multiple values in one variable name
The main program
The program written in C++, where comments are used to explain each action is as follows:
#include <iostream>
#include <vector>
using namespace std;
int main(){
//This declares the vector
vector<int> nums;
//This declares an integer variable
int num;
//Thie gets the first input
cin>>num;
//This loops is repeated until the user enters -1
while(num != -1){
nums.push_back(num);
cin>>num; }
//This iterates through the vector
for (auto i = nums.begin(); i != nums.end(); ++i){
//This checks if the current element is above 1
if(*i > 0){
//If yes, the element is printed
cout << *i <<endl;
}
}
return 0;
}
Read more about C++ programs at:
https://brainly.com/question/24027643
Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.