Listing 6
int LeftMostX(... array<Point^>^ points);
int main()
{
/*1*/ array<Point^>^ p = gcnew array<Point^> {
gcnew Point(10,3), gcnew Point(5,20), gcnew Point(-3, 4),
gcnew Point(1,30), gcnew Point(-5,2)
};
/*2*/ Console::WriteLine("LeftMostX is {0}", LeftMostX(p[1], p[3], p[0]));
/*3*/ Console::WriteLine("LeftMostX is {0}", LeftMostX(p));
}
int LeftMostX(... array<Point^>^ points)
{
/*4*/ int leftMostX = Int32::MaxValue;
for each (Point^ p in points)
{
if (p->X < leftMostX)
{
leftMostX = p->X;
}
}
return leftMostX;
}