如题,
C# codes as below:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Count(20));
Console.ReadKey();
}
static int Count(int n)
{
int number = 0;
for (int i = 1; i <= n / 3; i++)
{
int m = n - i;
for (int j = i; j <= m / 2; j++)
{
if (m - j - j < i)
{
number++;
Console.WriteLine("{0}, {1}, {2}",i,j,n-i-j);
}
}
}
return number;
}
Answer of the application:
2, 9, 9
3, 8, 9
4, 7, 9
4, 8, 8
5, 6, 9
5, 7, 8
6, 6, 8
6, 7, 7
8