有面值为1分,2分,5分的硬币共100枚,一共面值2.46圆,问每种硬币各有多少枚?.net编程解决
这么写就行了
using System;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int _1fen = 1;
int _2fen = 2;
int _5fen = 5;
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
for (int k = 0; k < 100; k++)
if (i + j + k == 100 && i * _1fen + j * _2fen + k * _5fen == 246)
Console.WriteLine("1分硬币{0}枚 2分硬币{1}枚 5分硬币{2}枚", i, j, k);
Console.WriteLine("按任意键退出");
Console.ReadKey();
}
}
}