M
mustangtiger24
Neues Mitglied
- 0
Wäre es vielleicht möglich, dass jemand mir den folgenden kurzen Code in android umschreibt. Ich beiss mir fast die Zähne aus :S
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static int[] Tags = new int[12] { 11, 96, 12, 33, 22, 63, 74, 52, 54, 42, 44, 85 };
static int[] Visited = new int[12];
static int iVisited = 0;
static void Main(string[] args)
{
Console.Write(Check(11, 96));
}
static bool Check(int pt, int target)
{
Visited[iVisited++] = pt;
if (InArray(Tags, pt + 1))
{
if (pt + 1 == target)
{
return true;
}
else if (!InArray(Visited, pt + 1))
{
if (Check(pt + 1, target))
{
return true;
}
}
}
if (InArray(Tags, pt + 11))
{
if (pt + 11 == target)
{
return true;
}
else if (!InArray(Visited, pt + 1))
{
if (Check(pt + 11, target))
{
return true;
}
}
}
if (InArray(Tags, pt + 10))
{
if (pt + 10 == target)
{
return true;
}
else if (!InArray(Visited, pt + 10))
{
if (Check(pt + 10, target))
{
return true;
}
}
}
if (InArray(Tags, pt + 9))
{
if (pt + 9 == target)
{
return true;
}
else if (!InArray(Visited, pt + 9))
{
if (Check(pt + 9, target))
{
return true;
}
}
}
if (InArray(Tags, pt - 1))
{
if (pt - 1 == target)
{
return true;
}
else if (!InArray(Visited, pt - 1))
{
if (Check(pt - 1, target))
{
return true;
}
}
}
if (InArray(Tags, pt - 11))
{
if (pt - 11 == target)
{
return true;
}
else if (!InArray(Visited, pt - 11))
{
if (Check(pt - 11, target))
{
return true;
}
}
}
if (InArray(Tags, pt - 10))
{
if (pt - 10 == target)
{
return true;
}
else if (!InArray(Visited, pt - 10))
{
if (Check(pt - 10, target))
{
return true;
}
}
}
if (InArray(Tags, pt - 9))
{
if (pt - 9 == target)
{
return true;
}
else if (!InArray(Visited, pt - 9))
{
if (Check(pt - 9, target))
{
return true;
}
}
}
return false;
}
static bool InArray(int[] arr, int val)
{
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] == val)
{
return true;
}
}
return false;
}
}
}