Find the best answers to your questions at Westonci.ca, where experts and enthusiasts provide accurate, reliable information. Get the answers you need quickly and accurately from a dedicated community of experts on our Q&A platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
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 stopping by. We are committed to providing the best answers for all your questions. See you again soon. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.