64 665
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #58223 in C++ for bong

Question #58223
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,
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions