for Ex 12 - 14

This commit is contained in:
2025-02-19 08:00:58 +01:00
parent 069a5890d1
commit 4b61367620
4 changed files with 89 additions and 5 deletions

View File

@@ -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
}
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}