Answer to Question #58223 in C++ for bong
write a program which produces the given sequence numbers (in alternative arrangement) using the three looping statements:
1,5,2,4,3,3,4,2,5,1,
1
2016-03-09T08:36:43-0500
#include<iostream>
#include <vector>
int main()
{
std::vector<int> Element;
int Number;
std::cout << "Please, enter number of sequence elements:" << std::endl;
std::cin >> Number;
std::cout << "Please, enter " << Number << " sequence elements:" << std::endl;
Element.resize(2*Number);
for(int i = 0; i < Number; i++)
{
std::cin >> Element[i];
}
for(int i = 0; i < Number; i++)
{
Element[Number + i] = Element[Number - i -1];
}
std::cout << "New sequence: " << std::endl;
for(int i = 0; i < 2*Number; i++)
{
std::cout << Element[i] << " ";
}
std::cout << std::endl;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment