标签:
//1元,2元,5元;凑够20元有多少种可能
int x = 0, y = 0, z = 0, m = 0;
while (x <= 20)
{
while (y <= 10)
{
while (z <= 4)
{
if (x + 2 * y + 5 * z == 20)
{
Console.WriteLine(x + "," + y + "," + z);
m++;
}
z++;
}
y++;
z = 0;
}
y = 0;
x++;
}
Console.WriteLine("总共有" + m + "种可能");
标签:
原文地址:http://www.cnblogs.com/lovesy2413/p/4311168.html