> We are not allowed to use vector.
> we are not allowed to use most of the libs like list<>.
> We have to make our own functions and structures.
>> so we'll have to do it with raw pointers and very careful memory allocation.
Or you can go ahead and create your own class that encapsulates the list behaviour.
Let's call it
nih::list<T>
1 2 3 4 5 6
|
struct field{
int id;
nih::list< int > points;
};
nih::list< field > foo;
|
you can do
1 2 3 4
|
namespace nih{
template <class T>
using list = std::list< T >;
}
|
to test your algorithms before having to create your own list., then just make sure to make it compatible.
> K stands for coordinates. Basicly it prints out which fields contains the point
If that's what you're interested in, then you may do it backwards.
Make a dictionary where the `key' is the point and the `value' is a list of the fields that have it.
> So ok, i can read the 1st ID and the method by " fin >> ID >> method" Then
> lets say i want to read fin >> AmountOfCords; which comes right after the
> method.... how do i do that?
you may do
fin >> AmountOfCords;
> And how do i move to a new line and start reading from a new line?
you know how many points will come to the end of the line, simply read those.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
while(fin >> ID >> method){
if(method == 'A'){
fin >> AmountOfCords;
int point;
for(int K=0; K<AmountOfCords; ++K){
fin>>point;
//...
}
}
else if(method == 'K'){
//...
}
}
|