Depends what you have so far. If you have the timePts from the file in an array or a vector then you can use a loop to run the array. If you have the timePts in a map then you can use the [] operator to look for a given timePt (not my first choice of containers, but you might be able to get it to work). If you have a tree or a list, then you can use a loop or recursion. Let's say you like to use vectors.
Then you could:
Code:
declare timePt class to include:
a data member which is a vector of ints called pt
a data member which is a vector of arrivalTimes
an overloaded << operator which displays the pt vector
declare an arrivalTime class to include:
an int for hour
an int for minute
an overloaded == operator
declare a vector of timePts called v to hold the timePt data from file
use an ifstream to read each timePt from file into v
The goal is to look for a timePt in v with three unique arrivalTimes supplied by user so:
declare a vector, desiredATs, to hold the desired arrivalTimes supplied by the user and obtain user input for each arrivalTime
declare iterators to run the vector of timePts:
std::vector<timePt>::iterator start = v.begin();
std::vector<timePt>::iterator stop = v.end();
use a loop to do the running from start to stop
within the loop check start->arrivalTimes vs
desiredATs for equality
if equality found then display value in start using the
<< operator
and break out of the loop
if you aren't familiar with vectors but you know about arrays and you can write your own list then you could:
Code:
declare timePt class to include:
a data member which is an array of ints called pt
a data member which is an array of arrivalTimes
an overloaded << operator which displays pt
declare an arrivalTime class to include:
an int for hour
an int for minute
an overloaded == operator
declare a node struct to include:
a timePt called data
a pointer to another node called next
declare a list of nodes called v to hold the timePt data from file
use an ifstream to read each timePt from file into a new node and add the new node to v
The goal is to look for a timePt in v with three unique arrivalTimes supplied by user so:
declare an array called desiredATs to hold the desired arrivalTimes supplied by the user and obtain user input for each arrivalTime
declare a node pointer called currentNode to run the list
use a loop to do the running from currentNode equals head until currentNode equals NULL
within the loop check currentNode->data.arrivalTimes vs
desiredATs for equality using a second loop to see
if each arrivalTime in desiredATs is in currentNode->data.arrivalTimes
if the two arrays match display currentNode->data
using the << operator
and break out of the loops
At least I think that approach will work. I haven't actually written code to confirm it.