GetMaxLength.cs

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static double GetMaxLength(double width, double height)
	{
		double result;
		// Переворачиваем лист, так чтобы ширина width была не меньше высоты height
		if (width < height)
		{
			double tmp = width;
			width = height;
			height = tmp;
		}
		
		if (width >= 3 * height)
		{
			result = height;
		}
		else
		{
			result = Math.Max(height / 2, width / 3);
		}
		
		return result;
	}	
	
	public static void Main()
	{
		Console.WriteLine("UniLecs");
		Console.WriteLine(string.Format("Answer = {0}", GetMaxLength(210, 297).ToString("0.00"))); // 105.0
		Console.WriteLine(string.Format("Answer = {0}", GetMaxLength(250, 100).ToString("0.00"))); // 83.33
	}
}
;