From 4b61367620088f3afc65d693b2652b61ab03e9e5 Mon Sep 17 00:00:00 2001 From: sebi Date: Wed, 19 Feb 2025 08:00:58 +0100 Subject: [PATCH] for Ex 12 - 14 --- Exercises/E11_For/Exercise_12.cs | 22 ++++++++++++++++++++++ Exercises/E11_For/Exercise_13.cs | 26 ++++++++++++++++++++++++++ Exercises/E11_For/Exercise_14.cs | 24 ++++++++++++++++++++++++ Program.cs | 22 +++++++++++++++++----- 4 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 Exercises/E11_For/Exercise_12.cs create mode 100644 Exercises/E11_For/Exercise_13.cs create mode 100644 Exercises/E11_For/Exercise_14.cs diff --git a/Exercises/E11_For/Exercise_12.cs b/Exercises/E11_For/Exercise_12.cs new file mode 100644 index 0000000..3f8e047 --- /dev/null +++ b/Exercises/E11_For/Exercise_12.cs @@ -0,0 +1,22 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; +using System.Dynamic; + +namespace Exercises_C_Sharp.E11_For; + +class Exercise_12 +{ + public static void Start() + { + + //Geben Sie auf der Konsole alle Zahlen von 1 bis 10 aus: + for (int i = 0; i < 10; i++) + { + //Code START + + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E11_For/Exercise_13.cs b/Exercises/E11_For/Exercise_13.cs new file mode 100644 index 0000000..090f579 --- /dev/null +++ b/Exercises/E11_For/Exercise_13.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; +using System.Dynamic; + +namespace Exercises_C_Sharp.E11_For; + +class Exercise_13 +{ + public static void Start() + { + int[] intArr = [2, 5, 1, 4, 6]; + string[] stringArr = ["Hallo", "Hey", "Hi", "Hoho", "Gogogo"]; + + //Sie sehen oben zwei Arrays. Das erste Array gibt an, wie oft Sie einen Wert aus dem zweiten Array (an der jeweiligen Stelle) ausgeben sollen. So sollen Sie "Hallo" 2x ausgeben, "Hey" 5x usw. Versuchen Sie, dies unabhängig von den Werten mit einer geschachtelten for-Schleife zu programmieren. + + + //Code START + + Console.WriteLine(intArr); + Console.WriteLine(stringArr); + + //Code ENDE + } +} \ No newline at end of file diff --git a/Exercises/E11_For/Exercise_14.cs b/Exercises/E11_For/Exercise_14.cs new file mode 100644 index 0000000..28727ba --- /dev/null +++ b/Exercises/E11_For/Exercise_14.cs @@ -0,0 +1,24 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; +using System.Dynamic; + +namespace Exercises_C_Sharp.E11_For; + +class Exercise_14 +{ + public static void Start() + { + int[] intArr = [2, 5, 1, -4, 6, 4, -5, 3, -2]; + + //Sie sehen oben ein Array mit Zahlen. Sie sollen nun von jeder Zahl bis 0 zählen. Versuchen Sie wieder, dies unabhängig von den Werten mit einer geschachtelten for-Schleife zu programmieren. + + + //Code START + + Console.WriteLine(intArr); + + //Code ENDE + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 64fb9a5..f7709d7 100644 --- a/Program.cs +++ b/Program.cs @@ -196,15 +196,27 @@ namespace Exercises_C_Sharp } }; //************************ - //***********FOR********** TODO + //***********FOR********** //************************ ExerciseGroup forElements = new() { Name = "11. for", - ElementList = new() - { - new(){Name = "Übung 1", Method = E18_Methods.Exercise_1.Start} - } + ElementList = [ + new(){Name = "Übung 1", Method = E11_For.Exercise_1.Start}, + new(){Name = "Übung 2", Method = E11_For.Exercise_2.Start}, + new(){Name = "Übung 3", Method = E11_For.Exercise_3.Start}, + new(){Name = "Übung 4", Method = E11_For.Exercise_4.Start}, + new(){Name = "Übung 5", Method = E11_For.Exercise_5.Start}, + new(){Name = "Übung 6", Method = E11_For.Exercise_6.Start}, + new(){Name = "Übung 7", Method = E11_For.Exercise_7.Start}, + new(){Name = "Übung 8", Method = E11_For.Exercise_8.Start}, + new(){Name = "Übung 9", Method = E11_For.Exercise_9.Start}, + new(){Name = "Übung 10", Method = E11_For.Exercise_10.Start}, + new(){Name = "Übung 11", Method = E11_For.Exercise_11.Start}, + new(){Name = "Übung 12", Method = E11_For.Exercise_12.Start}, + new(){Name = "Übung 13", Method = E11_For.Exercise_13.Start}, + new(){Name = "Übung 14", Method = E11_For.Exercise_14.Start} + ] }; //************************ //******Resize Array****** TODO