namespace _001年龄练习
{
class Program
{
/*
* 经理有3个女儿
*
* 女儿岁数之和是13
*
* 女儿岁数之积为经理岁数
*
* 女儿中只有一个大于5岁
*
*/
private static int firstDaughter, secondDaughter, thirdDaughter, manager;
static void Main(string[] args)
{
Logic();
Console.ReadKey();
}
public static void Logic()
{
for (int m = 13; m < 5 * 5 * 13; m++)
{
manager = m;
for (int i = 1; i < 6; i++)
{
for (int j = i; j < 6; j++)
{
int z = i + j;
if (13 - z >= 6 && i * j * (13 - z) == manager)
{
firstDaughter = i;
secondDaughter = j;
thirdDaughter = 13 - z;
Console.WriteLine(string.Format("设经理为{0}岁,则小女儿{1}岁,二女儿{2},大女儿{3}", manager, firstDaughter, secondDaughter, thirdDaughter));
break;
}
}
}
}
}
}
}
{
class Program
{
/*
* 经理有3个女儿
*
* 女儿岁数之和是13
*
* 女儿岁数之积为经理岁数
*
* 女儿中只有一个大于5岁
*
*/
private static int firstDaughter, secondDaughter, thirdDaughter, manager;
static void Main(string[] args)
{
Logic();
Console.ReadKey();
}
public static void Logic()
{
for (int m = 13; m < 5 * 5 * 13; m++)
{
manager = m;
for (int i = 1; i < 6; i++)
{
for (int j = i; j < 6; j++)
{
int z = i + j;
if (13 - z >= 6 && i * j * (13 - z) == manager)
{
firstDaughter = i;
secondDaughter = j;
thirdDaughter = 13 - z;
Console.WriteLine(string.Format("设经理为{0}岁,则小女儿{1}岁,二女儿{2},大女儿{3}", manager, firstDaughter, secondDaughter, thirdDaughter));
break;
}
}
}
}
}
}
}