Gut.
Hier wie vom Admin gefordert der bisherige Quellcode + genauere Fehlerbeschreibung:
class Program
{
static int x;
static int[][] Turmarray = new int[3][];
static void Main(string[] args)
{
x = 4;
Turmarray[0] = new int[x];
Turmarray[1] = new int[x];
Turmarray[2] = new int[x];
Start();
Verschiebe(0, 1);
}
static void Start()
{
int temp = x;
for (int i = 0; i < x; i++)
{
Turmarray[0][i] = temp;
temp--;
}
}
static void Verschiebe(int p_VonTurm, int p_NachTurm)
{
int a;
int b;
int c = 0;
int d = 1;
int Von = 0;
int Nach = 0;
a = SucheObersteScheibe(Turmarray[p_VonTurm]);
b = SucheObersteScheibe(Turmarray[p_NachTurm]);
if (Turmarray[p_NachTurm][0] != 0)
{
b = b - 1;
}
if (Turmarray[p_VonTurm][0] != 0)
{
a = a - 1;
}
Von = Turmarray[p_VonTurm][a];
Nach = Turmarray[p_NachTurm][b];
if (p_VonTurm == p_NachTurm)
{
d++;
Verschiebe(c, d);
}
else if (Von != 0 && Von < Nach || Turmarray[p_NachTurm][0] == 0)
{
SchreibeÄnderung(p_NachTurm, p_VonTurm, a, ;
c++;
Verschiebe(c, d);
}
else
{
Befehle(p_VonTurm, p_NachTurm, a, b );
}
}
static int SucheObersteScheibe(int[] p_Turm)
{
int i = 0;
while (i < p_Turm.Length && p_Turm[i] != 0)
{
i++;
}
return i;
}
static void SchreibeÄnderung(int p_NachTurm, int p_VonTurm, int a, int
{
if (Turmarray[p_NachTurm][0] != 0)
{
b = b + 1;
}
Turmarray[p_NachTurm][b] = Turmarray[p_VonTurm][a];
Turmarray[p_VonTurm][a] = 0;
}
static void Befehle(int p_VonTurm, int p_NachTurm, int a, int
{
int c = p_VonTurm;
int d = p_NachTurm;
// Befehl3
if (p_VonTurm == 0 && Turmarray[p_VonTurm][0] == 0)
{
c++;
d--;
d--;
Verschiebe(c,d);
}
// Befehl5
else if (Turmarray[p_NachTurm - 1][0] > Turmarray[p_NachTurm][b])
{
if (b == 1)
{
c++;
c++;
d--;
d--;
Verschiebe(c, d);
}
else
{
c++;
c++;
d--;
Verschiebe(c, d);
}
}
// Befehl4
else if (Turmarray[p_VonTurm][a] == 0 && Turmarray[p_VonTurm][a] < Turmarray[p_NachTurm][b] )
{
c++;
Verschiebe(c,d);
}
// Befehl2
else if (p_VonTurm == 0 && p_NachTurm == 2)
{
if (Turmarray[1][0] == 0)
{
d--;
Verschiebe(c, d);
}
else
{
c++;
Verschiebe(c,d);
}
}
// Befehl1
else if (p_VonTurm == 0 && p_NachTurm == 1)
{
Verschiebe(c,d);
}
}
}[/code]
Probleme gibts an Folgender "Turm-/ Arraykonstruktion"
4
1 3 2
hier ist es so das er zwar schreiben kann, es aber nicht soll.
Wie kann ich das unterbinden, bzw. mit welcher bedingung kann ich das unterbinden?
Hoffe das ist jetzt besser/ genauer vormuliert.
Hoffe das ist jetzt besser