I'm not sure what you are asking here. A general triangle does not have "legs". Is this a right triangle with legs x and y? In that case, the area is given by A= xy/2. If you are also required that 2x+y= 18 so that y= 18- 2x so the area is given by A= x(18- 2x)/2= 9x- x^2. That's a parabola and you can find a maximum value by completing the square.