ResizeArray, Foreach, While (angefangen...)
This commit is contained in:
23
Exercises/E12_ResizeArrays/Exercise_1.cs
Normal file
23
Exercises/E12_ResizeArrays/Exercise_1.cs
Normal 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] + " - ");
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Exercises/E12_ResizeArrays/Exercise_2.cs
Normal file
27
Exercises/E12_ResizeArrays/Exercise_2.cs
Normal 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] + " - ");
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Exercises/E12_ResizeArrays/Exercise_3.cs
Normal file
27
Exercises/E12_ResizeArrays/Exercise_3.cs
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user