ResizeArray, Foreach, While (angefangen...)

This commit is contained in:
2025-02-19 14:22:46 +01:00
parent 4b61367620
commit 361947b09e
14 changed files with 237 additions and 10 deletions

View File

@@ -0,0 +1,23 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Data.Common;
namespace Exercises_C_Sharp.E12_ResizeArray
{
class Exercise_1
{
public static void Start()
{
int[] arr = [13, 34, 234, 12, 345, 34];
//Fügen Sie dem oberen Array die Zahl 155 hinzu:
//Code START
//Code ENDE
for(int i = 0; i < arr.Length; i++)
Console.Write(arr[i] + " - ");
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Data.Common;
namespace Exercises_C_Sharp.E12_ResizeArray
{
class Exercise_2
{
public static void Start()
{
Random rand = new();
int random = rand.Next(5,20);
int[] arr = new int[random];
for(int i = 0; i < random; i++)
arr[i] = rand.Next(1,1000);
//Oben wir ein zufälliges Array erstellt. Sorgen Sie dafür, dass den Array eine zufällige Zahl hinzugefügt wird:
//Code START
//Code ENDE
for(int i = 0; i < arr.Length; i++)
Console.Write(arr[i] + " - ");
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Data.Common;
namespace Exercises_C_Sharp.E12_ResizeArray
{
class Exercise_3
{
public static void Start()
{
string[] userinputs = [];
//Lassen Sie den User 3 String eingeben. Diese sollen in das obere Array hineingeschrieben werden.
for(int i = 0; i < 3; i++)
{
//Code START
//Code ENDE
}
Console.Clear();
for(int i = 0; i < userinputs.Length; i++)
Console.WriteLine(userinputs[i]);
}
}
}