Hi. I've been reading C++ Primer, 4th Edition lately and have been attempting the excercises as I go along. I've done most of them. I've came across one which I don't really understand:
"Read a set of integers into a vector. Calculate and print the sum of each pair of adjacent elements in the vector. If there is an odd number, tell the user and print the value of the last element without summing it. Now change your program so that it prints the sum of the first and last elements, followed by the sum of the second and second-to-last and so on."
Right, I get the first sentence. But what does it mean with the second part (in bold)?
This is what I have so far:
Sorry for asking it here, but there is no answer book and you guys/girls are very smart.Code:#include <iostream> #include <vector> int main() { std::vector<int> Container; int ContainerSize = 10; int Temp = 0; for(int i = 0; i <= ContainerSize; i++) { std::cout << "Element " << i << ": "; std::cin >> Temp; Container.push_back(Temp); } }



LinkBack URL
About LinkBacks


