static void Main(string[] args)
{
int[,] aaa = { { 1, 6 }, { 9, 6 }, { 9, 13 }, { 12, 16 } };
int[,] bbb = { { 6, 7 }, { 6, 11 }, { 6, 2 }, { 16, 11 } };
int[,] ccc = { { 11, 6 }, { 7, 6 }, { 11, 16 } };
int i, j, k;
for (i = 0; i <= aaa.GetUpperBound(0); i++)
for (j = 0; j <= bbb.GetUpperBound(0); j++)
if (aaa[i, 1] == bbb[j, 0])
{
for (k = 0; k <= ccc.GetUpperBound(0); k++)
if (ccc[k, 0] == bbb[j, 1])
{
int[] direction = { aaa[i, 1], bbb[j, 1], ccc[k, 1] };
if (direction[0] != direction[2] &&
direction[1] != direction[2] &&
direction[0] != direction[1])
Console.WriteLine(string.Format("{0},{1} > {2},{3} > {4},{5}", aaa[i, 0], aaa[i, 1], bbb[j, 0], bbb[j, 1], ccc[k, 0], ccc[k, 1]));
}
}
Console.ReadKey();
}
The output will be:
1,6 > 6,11 > 11, 16
9,6 > 6,11 > 11,16
12,16 > 16,11 > 11,6
It takes an hour to solve it.
Accept it if I give you what you needed.