using System;
using System.IO;
using System.Collections.Generic;
namespace Combinations01
{
class Program
{
static void Main(string[] args)
{
int k = 1;
double vdForce = 0, vdTempVar;
using (StreamWriter objWriter
= new StreamWriter
(@"C:\Combinations.txt")) {
for (int count = 1; count <= 6; count++)
{
foreach (var c
in CombinationsWithRepition
(new int[] { 301,
305,
347 }, count
)) {
foreach (var vf in c)
{
vdTempVar = 100;
if (vf == 305) vdTempVar = 200;
if (vf == 347) vdTempVar = 300;
vdForce = vdForce + vdTempVar;
}
objWriter.WriteLine("{0,4} -> {1} = {2}", k, c, vdForce);
k = k + 1;
vdForce = 0;
}
}
}
}
static IEnumerable<String> CombinationsWithRepition(IEnumerable<int> input, int length)
{
if (length <= 0)
yield return "";
else
{
foreach (var i in input)
foreach (var c in CombinationsWithRepition(input, length - 1))
yield return i.ToString() + " " + c;
}
}
}
}