View Single Post
Old Dec 1st, 2006, 3:21 PM   #51
aznballerlee
Hobbyist Programmer
 
Join Date: Nov 2006
Posts: 111
Rep Power: 2 aznballerlee is on a distinguished road
In other words, I tried and this is what I got. Correct?

Robot* otherRobotAt(Robot* rp) const
//      If there is at least one robot (other than the one rp points to)
//      at the same (r,c) coordinates as the one rp points to, return a
//      pointer to the one of those other robots with the least amount
//      of energy remaining (if there's a tie, any one of the tied robots
//      will do); otherwise, return NULL.
//
{
	for (int i = 0; i< m_nrobots; i++)
	{
		if ((m_robots[i] -> row()==r)
			&& (m_robots[i] -> col()==c)
			return this; 
	}
	return NULL;
}
aznballerlee is offline   Reply With Quote