E26 Ex 3 - 6
This commit is contained in:
parent
a6946a9270
commit
098cd0697f
@ -21,7 +21,13 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
|||||||
static int[,] ReverseArray(int[,] arr)
|
static int[,] ReverseArray(int[,] arr)
|
||||||
{
|
{
|
||||||
//Code START
|
//Code START
|
||||||
return new int[0,0];
|
int[,] tempArr = new int[arr.GetLength(1), arr.GetLength(0)];
|
||||||
|
|
||||||
|
for (int i = 0; i < arr.GetLength(0); i++)
|
||||||
|
for (int j = 0; j < arr.GetLength(1); j++)
|
||||||
|
tempArr[j, i] = arr[i, j];
|
||||||
|
|
||||||
|
return tempArr;
|
||||||
//Code ENDE
|
//Code ENDE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +35,14 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
|||||||
static void ShowArray(int[,] arr)
|
static void ShowArray(int[,] arr)
|
||||||
{
|
{
|
||||||
//Code START
|
//Code START
|
||||||
|
for (int i = 0; i < arr.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < arr.GetLength(1); j++)
|
||||||
|
Console.Write(arr[i, j] + "\t");
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine("----------------");
|
||||||
//Code ENDE
|
//Code ENDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,12 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
|||||||
static int[,] RemoveEven(int[,] arr)
|
static int[,] RemoveEven(int[,] arr)
|
||||||
{
|
{
|
||||||
//Code START
|
//Code START
|
||||||
return new int[0,0];
|
for (int i = 0; i < arr.GetLength(0); i++)
|
||||||
|
for (int j = 0; j < arr.GetLength(1); j++)
|
||||||
|
if (arr[i, j] % 2 == 0)
|
||||||
|
arr[i, j] = -1;
|
||||||
|
|
||||||
|
return arr;
|
||||||
//Code ENDE
|
//Code ENDE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +38,12 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
|||||||
static int[,] RemoveOdd(int[,] arr)
|
static int[,] RemoveOdd(int[,] arr)
|
||||||
{
|
{
|
||||||
//Code START
|
//Code START
|
||||||
return new int[0,0];
|
for (int i = 0; i < arr.GetLength(0); i++)
|
||||||
|
for (int j = 0; j < arr.GetLength(1); j++)
|
||||||
|
if (arr[i, j] % 2 != 0)
|
||||||
|
arr[i, j] = -1;
|
||||||
|
|
||||||
|
return arr;
|
||||||
//Code ENDE
|
//Code ENDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,14 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
|||||||
//Lassen Sie den Nutzer das zweidimensionale Array 'stringArray' mit (9, jeweils eine pro Feld) Eingaben befüllen
|
//Lassen Sie den Nutzer das zweidimensionale Array 'stringArray' mit (9, jeweils eine pro Feld) Eingaben befüllen
|
||||||
|
|
||||||
//Code START
|
//Code START
|
||||||
|
for (int i = 0; i < stringArray.GetLength(0); i++)
|
||||||
|
for (int j = 0; j < stringArray.GetLength(1); j++)
|
||||||
|
stringArray[i, j] = Console.ReadLine() ?? "";
|
||||||
//Code ENDE
|
//Code ENDE
|
||||||
|
|
||||||
//Überprüfung:
|
//Überprüfung:
|
||||||
foreach(var element in stringArray)
|
foreach (var element in stringArray)
|
||||||
Console.Write(element + " - ");
|
Console.Write(element + " - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user