FlowChart, SwitchCase, For
This commit is contained in:
23
Exercises/E11_For/Exercise_1.cs
Normal file
23
Exercises/E11_For/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.E11_For
|
||||
{
|
||||
class Exercise_1
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Sorgen Sie dafür, dass auf der Konsole 7 ausgegeben wird:
|
||||
//Code START
|
||||
string s = string.Empty;
|
||||
//Code ENDE
|
||||
|
||||
int counter = 0;
|
||||
for(int i = 0; i < s.Length; i++)
|
||||
counter++;
|
||||
Console.WriteLine(counter);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Exercises/E11_For/Exercise_10.cs
Normal file
29
Exercises/E11_For/Exercise_10.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_10
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
int[] intArray = [12, 45, 56, 23, 56, 345, 56, 56];
|
||||
|
||||
//Geben Sie mit Hilfe der For-Schleife alle Zahlen im Array aus:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
|
||||
//Multiplizieren Sie mit Hilfe der For-Schleife alle Zahlen im Array mit 2:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
|
||||
//Geben Sie nun mit Hilfe der For-Schleife alle Zahlen im Array aus:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
23
Exercises/E11_For/Exercise_11.cs
Normal file
23
Exercises/E11_For/Exercise_11.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_11
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
int[] intArray = [12, 45, 56, 23, 56, 345, 56, 56];
|
||||
|
||||
//Lösen Sie die vorherige Aufgabe mit nur einer For-Schleife:
|
||||
// - Geben Sie mit Hilfe der For-Schleife alle Zahlen im Array aus:
|
||||
// - Multiplizieren Sie mit Hilfe der For-Schleife alle Zahlen im Array mit 2:
|
||||
// - Geben Sie nun mit Hilfe der For-Schleife alle Zahlen im Array aus:
|
||||
//Code START
|
||||
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
21
Exercises/E11_For/Exercise_2.cs
Normal file
21
Exercises/E11_For/Exercise_2.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For
|
||||
{
|
||||
class Exercise_2
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Sorgen Sie dafür, dass auf der Konsole "Hallo" ausgegeben wird:
|
||||
//Code START
|
||||
string s = string.Empty;
|
||||
//Code ENDE
|
||||
|
||||
for(int i = s.Length -1; i > 0; i--)
|
||||
Console.Write(s[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Exercises/E11_For/Exercise_3.cs
Normal file
22
Exercises/E11_For/Exercise_3.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_3
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Lassen Sie den User eine Zahl eingeben:
|
||||
//Code START
|
||||
int userinput = -1;
|
||||
//Code ENDE
|
||||
|
||||
//Geben Sie so oft auf der Konsole das Wort "Hallo!" mit Hilfe einer For-Schleife aus:
|
||||
//Code START
|
||||
userinput *= -1;
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
27
Exercises/E11_For/Exercise_4.cs
Normal file
27
Exercises/E11_For/Exercise_4.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_4
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Lassen Sie den User eine Zahl eingeben:
|
||||
//Code START
|
||||
int userinput = -1;
|
||||
//Code ENDE
|
||||
|
||||
//Überprüfen Sie die Zahl, ob diese zwischen 1 und 100 liegt
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
|
||||
//Wenn die Zahl in dem Bereich liegt, dann geben Sie alle Zahlen von 0 bis zu dieser Zahl auf der Konsole aus:
|
||||
//Code START
|
||||
userinput *= -1;
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
27
Exercises/E11_For/Exercise_5.cs
Normal file
27
Exercises/E11_For/Exercise_5.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_5
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Lassen Sie den User eine Zahl eingeben:
|
||||
//Code START
|
||||
int userinput = -1;
|
||||
//Code ENDE
|
||||
|
||||
//Überprüfen Sie die Zahl, ob diese zwischen 1 und 100 liegt
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
|
||||
//Wenn die Zahl in dem Bereich liegt, dann geben Sie alle Zahlen von dieser Zahl bis 0 auf der Konsole aus:
|
||||
//Code START
|
||||
userinput *= -1;
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
19
Exercises/E11_For/Exercise_6.cs
Normal file
19
Exercises/E11_For/Exercise_6.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_6
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
int[] intArray = [12, 45, 56, 23, 56, 345, 56, 56];
|
||||
|
||||
//Geben Sie alle Zahlen im obrigen Array mit Hilfe der For-Schleife auf der Konsole aus
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
19
Exercises/E11_For/Exercise_7.cs
Normal file
19
Exercises/E11_For/Exercise_7.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_7
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
string[] intArray = ["Hallo", "Hey", "Hi", "Grüß Gott", "Guten Morgen", "Guten Tag", "Servus", "Ciao"];
|
||||
|
||||
//Geben Sie alle Zahlen im obrigen Array mit Hilfe der For-Schleife nummeriert von 1 bis 8 auf der Konsole aus:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
19
Exercises/E11_For/Exercise_8.cs
Normal file
19
Exercises/E11_For/Exercise_8.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_8
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
int[] intArray = [12, 45, 56, 23, 56, 345, 56, 56];
|
||||
|
||||
//Bilden Sie die Summe der Zahlen oben mit einer For-Schleife und geben Sie diese auf der Konsole aus:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
22
Exercises/E11_For/Exercise_9.cs
Normal file
22
Exercises/E11_For/Exercise_9.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Exercises_C_Sharp.E11_For;
|
||||
|
||||
class Exercise_9
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
//Lassen Sie dem User eine Zahl zwischen 1 und 15 eingeben:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
|
||||
//Multiplizieren Sie dann die Zahl 2 mit Hilfe einer For-Schleife so oft mit sich selber, wie vom User oben eingegeben, und geben Sie dann das Ergebnis aus:
|
||||
//Code START
|
||||
|
||||
//Code ENDE
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user