+ 1
Help with ticket office problem in c++.
Hi, I'm very new to coding and I dont umderstand how to answer this question at all or where to begin. I suppose my first question is what does the initial code do, this one: #include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here return 0; } If someone can walk me through this I would be very greatful.
2 Réponses
+ 2
The code for taking input is already written, you just need to apply logic that will lead to expected output. Read the question carefully and try to code.
+ 1
The code already written runs a loop 5 times, each time the loop iterates it asks for an input (that the SoloLearn test case sends) and saves that input in the array ages[ ], eg first input might be 15 so ages[0] will have the value 15, second input might be 42 so ages[1] will have the value 42.
Your first thing to do is come up with the ideas/logic/strategy. ✅
You might know some of the math that needs to be done (post it here if you do)
or you might know that you need to access the value that has been saved to ages[0], and compare it to something, the outcome of the comparison might change what you do next. Post your logic here and we will help you.