CSharp · Console
using System;
public class Program
{
private static bool[,] horizontal = new bool[10, 10];
private static bool[,] vertical = new bool[10, 10];
private static void Build()
{
for (int i = 0; i < vertical.GetLength(0); i++)
{
for(int j = 0; j < vertical.GetLength(1); j++)
{
vertical[i,j] = false;
}
}
for (int i = 0; i < horizontal.GetLength(0); i++)
{
for(int j = 0; j < horizontal.GetLength(1); j++)
{
horizontal[i,j] = false;
}
}
}
private static void InvokeMe()
{
int hz = horizontal.GetLength(0) * horizontal.GetLength(1);
int vr = vertical.GetLength(0) * vertical.GetLength(1);
int hzcol = horizontal.GetLength(1);
int vrcol = vertical.GetLength(1);
//Determine true from Horizontal information:
for (int i = 0; i < hz; i++)
{
if(horizontal[i / hzcol, i % hzcol] == true)
System.Console.WriteLine("True, on position: {0},{1}", i / hzcol, i % hzcol);
}
//Determine true position from vertical information:
for (int i = 0; i < vr; i++)
{
if(vertical[i / vrcol, i % vrcol] == true)
System.Console.WriteLine("True, on position: {0},{1}", i / vrcol, i % vrcol);
}
}
public static void Main()
{
Build();
do
{
InvokeMe(); // This would run many times over, during game session.
}
while(true);
}
}