code:Answer B:template <class T>
bool CheckList (T *Start)
{
T *Current = Start;
while (Current != NULL) {
if (Current == Start) return true;
Current = Current->Next;
}
return false;
}
code:Hobbestemplate <class T>
bool CheckList (T *Start)
{
T *Current;
T *Mov;
int StartCount;
Current = Start;
for (int ObjectsTo = 0; true; ObjectsTo++) {
if (Current == NULL) return false;
Move = Start;
for (StartCount = 0; Move != Current; StartCount++) {}
if (StartCount < ObjectsTo) return true;
Current = Current->Next;
}
return false;
}
quote:Yup. I got the answer, stared at it, mused as to whether it was right -- and fugu had posted.
The math's easy, but the result is counterintuitive to most people.