E26 Ex 1 -3
This commit is contained in:
parent
6cad6b98b2
commit
a6946a9270
@ -14,8 +14,23 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
||||
//Führen Sie diese drei oben gezeigten Arrays zu einem Array zusammen
|
||||
|
||||
//Code START
|
||||
int[,] ints = new int[3, 6] {
|
||||
{12,45,21,34,12,45},
|
||||
{152,475,211,734,812,455},
|
||||
{1722,4565,2123,3452,12121,3315}
|
||||
};
|
||||
|
||||
// ODER:
|
||||
int[,] ints2 = new int[3, 6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ints2[0, i] = array1[i];
|
||||
ints2[1, i] = array2[i];
|
||||
ints2[2, i] = array3[i];
|
||||
}
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,8 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
||||
//Sorgen Sie dafür, dass auf der Konsole die Zahl 2565 ausgegeben wird.
|
||||
|
||||
//Code START
|
||||
dynamic array = -1;
|
||||
int[,] array = new int[6,5];
|
||||
array[1, 4] = 2565;
|
||||
//Code ENDE
|
||||
|
||||
MakeSomething(array);
|
||||
|
||||
@ -17,6 +17,20 @@ namespace Exercises_C_Sharp.E26_Mehrdimensionale_Arrays
|
||||
//Geben Sie das 2-dimensionale Feld auf der Konsole aus. Geben Sie zu jeder Zeile und zu jeder Spalte die jewilige Summe mit aus.
|
||||
|
||||
//Code START
|
||||
int[] sums = new int[intArray.GetLength(1)];
|
||||
for (int i = 0; i < intArray.GetLength(0); i++)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int j = 0; j < intArray.GetLength(1); j++)
|
||||
{
|
||||
Console.Write(intArray[i, j] + " ");
|
||||
sum += intArray[i, j];
|
||||
sums[j] += intArray[i, j];
|
||||
}
|
||||
Console.WriteLine(sum);
|
||||
}
|
||||
foreach (var element in sums)
|
||||
Console.Write(element + " ");
|
||||
|
||||
//Code ENDE
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user