> I know it is very easy, but I just can't fngure out the algorithm.
> For example: I have these:
[quoted text clipped - 3 lines]
>
> How to write an algorithm to print all the combinations like:
This seems a school exercise. I hope this isn't a school exercise.
foreach (int i in b)
{
foreach (int j in a)
{
foreach (int k in c)
{
Console.WriteLine("{0} {1} {2}", i, j, k);
}
}
}
And you even copied it wrong I think. You wrote twice:
> 2 b d
> 2 b e
> 2 b f
Moty Michaely - 25 May 2007 12:20 GMT
> > I know it is very easy, but I just can't fngure out the algorithm.
> > For example: I have these:
[quoted text clipped - 23 lines]
> > 2 b e
> > 2 b f
Maybe that's why he needs a computer to do it :)
Michael A. Covington - 25 May 2007 15:17 GMT
>> I know it is very easy, but I just can't fngure out the algorithm.
>> For example: I have these:
[quoted text clipped - 16 lines]
> }
> }
Right. I see you deliberately left a small error in, as an exercise for the
student.
Bill Butler - 25 May 2007 16:15 GMT
>> I know it is very easy, but I just can't fngure out the algorithm.
>> For example: I have these:
[quoted text clipped - 16 lines]
> }
> }
Of course, since the arrays contain strings this will fail to run, but
the basic premise is correct.
Bill