output All Options Of 2D Array

a906290

New member
Joined
Aug 18, 2014
Messages
3
Programming Experience
Beginner
I am developing a gambling helper app for PC.
In the gambling game there are 13 games of goal, each game has 3 options: (1) - for the first group to win, (0) - the result ends in a draw, (2) - for the second group to win.
I created a char 2d array with the size of 13x3 which the user inputs ('x' for selecting the option, 'o' for not selecting it), here is the code to make things clear:

C#:
char[,] ch = new char[13,3]
for (int i = 0; i < 13; i++)
{
  Console.WriteLine("Enter Game{0}:", i+1);

  Console.Write("If you think group1 will win enter 'x', if not enter 'o': ");
  ch[i,0] = char.Parse(Console.ReadLine());

  Console.Write("If you think the game will end in draw 'x', if not enter 'o': ");
  ch[i,1] = char.Parse(Console.ReadLine());

  Console.Write("If you think group2 will win enter 'x', if not enter 'o': ");
  ch[i,2] = char.Parse(Console.ReadLine());

}

This allows the user to select each option which he thinks that could take place (there can be more than one option for a certain game in this algorithme, but this is not the case with a real form game).

What I do not know how to do it efficiently is how to print all possible options (from the user's selection)
what I did was that I randomized the options and looped until all of them were printed (but surely very not efficient way to do things)
any help is highly appreciated
 
Last edited:
Just as you have looped through the array to get the input, so you would loop through it to output it. You might use two nested loops to cover the two dimensions or you might just hard-code three writes per game with a single loop as you have done for the input. How exactly are you expecting the output to look?
 
Just as you have looped through the array to get the input, so you would loop through it to output it. You might use two nested loops to cover the two dimensions or you might just hard-code three writes per game with a single loop as you have done for the input. How exactly are you expecting the output to look?

the goal of the 2D array is allowing the user to fill in all options for a certain game,the game in the real form can have only one, however the output there must be a combination of all 13 games with different results.
to make things clear, the input could look something like this:

the first column (column0) represents the outcome '1' (first group can win)
the second coulumn (column1) represents the outcome '0' (can end in draw)
the third column (column2) represents the outcome '2' (second group can win)


....012
...____
0 |xxo //Game1
1 |xoo //Game2
2 |oxx //Game3
3 |xxo //Game4
4 |oox //Game5
5 |oox //Game6
6 |oxo //Game7
7 |xoo //Game8
8 |xoo //Game9
9 |oox //Game10
10|xxo //Game11
11|xxx //Game12
12|oxo //Game13

(o - means left clear, x - means option selected)
I am not planning to output the 2d array as it is.

in real life form however you can't enter more that one 'x' into a certain game. this app is intended so that you can enter all possible options you think the result would be and print all possible combinations, for instance from the above 2d array there are 48 options (2x1x2x2x1x1xx1x1x1x1x2x3x1)
here are examples of 2 of them:

0101220112110 (the column index of the maching game - the first '0' is a possible outcome of game1, the first 1 is a possible outcome of game2, etc)

1120220112020

here is an output that can't be displayed
2212220112202

hope that helped explain my intentions.
 
Back
Top Bottom