From 5b878e859d0d6d98bd3d1af4c0a32ab9f3d4abc4 Mon Sep 17 00:00:00 2001 From: Jens Albrecht <jens.albrecht@th-nuernberg.de> Date: Tue, 5 Nov 2024 09:56:56 +0100 Subject: [PATCH] . --- EinmalEins/EinmalEins.cs | 7 +++++ EinmalEins/EinmalEins.csproj | 10 +++++++ HarmonischeReihe/HarmonischeReihe.cs | 14 +++++++++ HarmonischeReihe/HarmonischeReihe.csproj | 10 +++++++ Kindergeburtstag/Kindergeburtstag.cs | 17 +++++++++++ Kindergeburtstag/Kindergeburtstag.csproj | 10 +++++++ Uebung04.sln | 37 ++++++++++++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 EinmalEins/EinmalEins.cs create mode 100644 EinmalEins/EinmalEins.csproj create mode 100644 HarmonischeReihe/HarmonischeReihe.cs create mode 100644 HarmonischeReihe/HarmonischeReihe.csproj create mode 100644 Kindergeburtstag/Kindergeburtstag.cs create mode 100644 Kindergeburtstag/Kindergeburtstag.csproj create mode 100644 Uebung04.sln diff --git a/EinmalEins/EinmalEins.cs b/EinmalEins/EinmalEins.cs new file mode 100644 index 0000000..aa8b095 --- /dev/null +++ b/EinmalEins/EinmalEins.cs @@ -0,0 +1,7 @@ +for (int i = 1; i <= 10; i++) +{ + for (int j = 1; j <= 10; j++) + Console.Write($"{i*j,4}"); + + Console.WriteLine(); +} \ No newline at end of file diff --git a/EinmalEins/EinmalEins.csproj b/EinmalEins/EinmalEins.csproj new file mode 100644 index 0000000..40c60dd --- /dev/null +++ b/EinmalEins/EinmalEins.csproj @@ -0,0 +1,10 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/HarmonischeReihe/HarmonischeReihe.cs b/HarmonischeReihe/HarmonischeReihe.cs new file mode 100644 index 0000000..a398010 --- /dev/null +++ b/HarmonischeReihe/HarmonischeReihe.cs @@ -0,0 +1,14 @@ +Console.WriteLine("Berechnung der harmonischen Reihe"); +Console.Write("Bis zu welchem n? "); +string? eingabe = Console.ReadLine(); +int n = Convert.ToInt32(eingabe); + +double summe = 0; + +for (int i = 1; i <= n; i++) +{ + summe += 1.0 / i; +} + +Console.WriteLine($"Summe bis 1/{n}: {summe}"); + diff --git a/HarmonischeReihe/HarmonischeReihe.csproj b/HarmonischeReihe/HarmonischeReihe.csproj new file mode 100644 index 0000000..206b89a --- /dev/null +++ b/HarmonischeReihe/HarmonischeReihe.csproj @@ -0,0 +1,10 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/Kindergeburtstag/Kindergeburtstag.cs b/Kindergeburtstag/Kindergeburtstag.cs new file mode 100644 index 0000000..97f9cd3 --- /dev/null +++ b/Kindergeburtstag/Kindergeburtstag.cs @@ -0,0 +1,17 @@ +string eingabe; + +Console.Write("Anzahl Kinder eingeben: "); +eingabe = Console.ReadLine()!; +int anzahlKinder = Convert.ToInt32(eingabe); + +Console.Write("Anzahl Ü-Eier eingeben: "); +eingabe = Console.ReadLine()!; +int anzahlEier = Convert.ToInt32(eingabe); + +int eierProKind = anzahlEier / anzahlKinder; +int eierUebrig = anzahlEier % anzahlKinder; + +Console.WriteLine("Es werden " + eierProKind + " pro Kind verteilt. " + + eierUebrig + " Eier bleiben übrig."); + +Console.ReadKey(); diff --git a/Kindergeburtstag/Kindergeburtstag.csproj b/Kindergeburtstag/Kindergeburtstag.csproj new file mode 100644 index 0000000..206b89a --- /dev/null +++ b/Kindergeburtstag/Kindergeburtstag.csproj @@ -0,0 +1,10 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/Uebung04.sln b/Uebung04.sln new file mode 100644 index 0000000..16d6631 --- /dev/null +++ b/Uebung04.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EinmalEins", "EinmalEins\EinmalEins.csproj", "{4939D887-29D6-4800-8DA9-4FF1E6E5FEA4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kindergeburtstag", "Kindergeburtstag\Kindergeburtstag.csproj", "{724827E2-A9EF-45DD-A431-BAA815CF966E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarmonischeReihe", "HarmonischeReihe\HarmonischeReihe.csproj", "{04D58E21-6687-4C38-AEAD-6A977ECB7E2E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4939D887-29D6-4800-8DA9-4FF1E6E5FEA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4939D887-29D6-4800-8DA9-4FF1E6E5FEA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4939D887-29D6-4800-8DA9-4FF1E6E5FEA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4939D887-29D6-4800-8DA9-4FF1E6E5FEA4}.Release|Any CPU.Build.0 = Release|Any CPU + {724827E2-A9EF-45DD-A431-BAA815CF966E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {724827E2-A9EF-45DD-A431-BAA815CF966E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {724827E2-A9EF-45DD-A431-BAA815CF966E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {724827E2-A9EF-45DD-A431-BAA815CF966E}.Release|Any CPU.Build.0 = Release|Any CPU + {04D58E21-6687-4C38-AEAD-6A977ECB7E2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04D58E21-6687-4C38-AEAD-6A977ECB7E2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04D58E21-6687-4C38-AEAD-6A977ECB7E2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04D58E21-6687-4C38-AEAD-6A977ECB7E2E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BC209A6A-839D-4764-BCF6-9548CA104068} + EndGlobalSection +EndGlobal -- GitLab