diff --git a/04 Do_While_Schleife/Program.cs b/04 Do_While_Schleife/Program.cs index c268e67b152ac880d6405c4b84606b99d1b21561..3a2b6c564eb012585cb6e5087ca79b44b56aa628 100644 --- a/04 Do_While_Schleife/Program.cs +++ b/04 Do_While_Schleife/Program.cs @@ -6,19 +6,19 @@ namespace _04_Do_While_Schleife { static void Main(string[] args) { - bool falscheEingabe; + bool eingabeNochNichtRichtig; int zahl; do { Console.Write("Geben Sie eine Zahl zwischen 10..20 ein: "); zahl = Convert.ToInt32(Console.ReadLine()); - falscheEingabe = zahl < 10 || zahl > 20; + eingabeNochNichtRichtig = zahl < 10 || zahl > 20; - if (falscheEingabe) + if (eingabeNochNichtRichtig) Console.WriteLine("Falsche Eingabe! Nur Zahlen von 10..20!"); - } while (falscheEingabe); + } while (eingabeNochNichtRichtig); ////////////////////////////////////////////////////////// diff --git a/04 Funktionen_2/Program.cs b/04 Funktionen_2/Program.cs index 2da0d2799dc9542de7c7da668d62a08f321c9326..e0ebaa5aa2e07dda4e610fa47d340422a5a7389a 100644 --- a/04 Funktionen_2/Program.cs +++ b/04 Funktionen_2/Program.cs @@ -39,7 +39,7 @@ namespace _04_Funktionen_2 Incr_ByVal(20); // Incr(20) erg=Incr_ByVal(zahl); // Incr(10) Incr_ByVal(zahl * zahl); // Incr(100) - //Incr(Convert.ToInt32(Console.ReadLine())); // Eingabe: "123" --> Incr(123) + //Incr_ByVal(Convert.ToInt32(Console.ReadLine())); // Eingabe: "123" --> Incr(123) Fakultaet(3); diff --git a/05 Datentyp_Char/05 Datentyp_Char.csproj b/05 Datentyp_Char/05 Datentyp_Char.csproj new file mode 100644 index 0000000000000000000000000000000000000000..12a61f94170b2df3c9a44e77f3e6b98ab0bd03a0 --- /dev/null +++ b/05 Datentyp_Char/05 Datentyp_Char.csproj @@ -0,0 +1,9 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>netcoreapp3.1</TargetFramework> + <RootNamespace>_05_Datentyp_Char</RootNamespace> + </PropertyGroup> + +</Project> diff --git a/05 Datentyp_Char/Program.cs b/05 Datentyp_Char/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..e0a5af543b94bbc08d076d8d7181387ff875f155 --- /dev/null +++ b/05 Datentyp_Char/Program.cs @@ -0,0 +1,31 @@ +using System; + +namespace _05_Datentyp_Char +{ + class Program + { + static void Main(string[] args) + { + int x = 21; + double d = 3.14; + bool b = true; + string s = "Hallo"; // DOPPELTE Anführungszeichen + + char c = 'A'; // EINFACHE Anführungszeichen + + Console.WriteLine("Gib ein Zeichen ein: "); + char key=' '; + do + { + if (Console.KeyAvailable) // Ist (irgendeine) Taste gedrückt worden? + { + key = Console.ReadKey(true).KeyChar; // gedrücktes Zeichen + if (key== 'a') + Console.WriteLine("Auto nach links"); + else if (key== 'd') + Console.WriteLine("Auto nach rechts"); + } + } while (key != 'x'); + } + } +} diff --git a/05 Uebung_Mo/05 Uebung_Mo.csproj b/05 Uebung_Mo/05 Uebung_Mo.csproj new file mode 100644 index 0000000000000000000000000000000000000000..391c600735f99fafd5106d62b7977e6e49c33037 --- /dev/null +++ b/05 Uebung_Mo/05 Uebung_Mo.csproj @@ -0,0 +1,9 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>netcoreapp3.1</TargetFramework> + <RootNamespace>_05_Uebung_Mo</RootNamespace> + </PropertyGroup> + +</Project> diff --git a/05 Uebung_Mo/Program.cs b/05 Uebung_Mo/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..0fb8c24fed3002281f05c9cb21457c0639e7ee60 --- /dev/null +++ b/05 Uebung_Mo/Program.cs @@ -0,0 +1,41 @@ +using System; + +namespace _05_Uebung_Mo +{ + class Program + { + static void powers(double x, out double xx, ref double xxx) + // ref xx = 100.000 + // ref xxx = 200.000 + { + xx = x * x; // Speichere an der Stelle 100.000 den Wert von x*x + xxx = x * x * x; // Speichere an der Stelle 200.000 den Wert von x*x*x + } + + static (double,double) powers_Tupel(double x) + { + return (x * x, x * x * x); + } + static void Main(string[] args) + { + double x2, x3=0; // Annahme: Speicheradr. von x2 = 100.000 + // Annahme: Speicheradr. von x3 = 200.000 + powers(2+1, out x2, ref x3); // powers(3, 100.000, 200.000) + Console.WriteLine($"x2 = {x2}, x3 = {x3}"); + + // Übergabe per ref + // Übergebene Variable muss vor Verwendung initialisiert sein + // Veränderung in der aufgerufenen Funktion optional + // Zusicherung an die aufgerufene Funktion, dass der Var.Wert + // sinnvoll ist + + // Übergabe per out + // Übergebene Variable muss nicht vor der Verwendung initialisiert sein + // Veränderung in der aufgerufenen Funktion wird sichergestellt + // Keine Zusicherung an die aufgerufene Funktion, dass der Var.Wert + // sinnvoll ist + + (x2, x3) = powers_Tupel(3); + } + } +} diff --git a/Prog1_WS2021_22.sln b/Prog1_WS2021_22.sln index 53488709362d285446ece17b50939a7a148ddaed..03ac1ccffc5b69ffbb024b43589778c013c697e3 100644 --- a/Prog1_WS2021_22.sln +++ b/Prog1_WS2021_22.sln @@ -37,7 +37,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 Dreiecke_Mo_Ubg", "04 Dr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 Uebung_Di", "04 Uebung_Di\04 Uebung_Di.csproj", "{F17A5B61-A944-4719-8CBA-BBD034A73B96}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04 Funktionen_2", "04 Funktionen_2\04 Funktionen_2.csproj", "{258D6D4B-BECB-44FA-A15A-2C310EBD9477}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 Funktionen_2", "04 Funktionen_2\04 Funktionen_2.csproj", "{258D6D4B-BECB-44FA-A15A-2C310EBD9477}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "05 Uebung_Mo", "05 Uebung_Mo\05 Uebung_Mo.csproj", "{BCD60EC3-A134-48B8-8A40-093C3702D748}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "05 Datentyp_Char", "05 Datentyp_Char\05 Datentyp_Char.csproj", "{30CD32DF-7134-492E-8F48-BB5A8B473B51}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -117,6 +121,14 @@ Global {258D6D4B-BECB-44FA-A15A-2C310EBD9477}.Debug|Any CPU.Build.0 = Debug|Any CPU {258D6D4B-BECB-44FA-A15A-2C310EBD9477}.Release|Any CPU.ActiveCfg = Release|Any CPU {258D6D4B-BECB-44FA-A15A-2C310EBD9477}.Release|Any CPU.Build.0 = Release|Any CPU + {BCD60EC3-A134-48B8-8A40-093C3702D748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCD60EC3-A134-48B8-8A40-093C3702D748}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCD60EC3-A134-48B8-8A40-093C3702D748}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCD60EC3-A134-48B8-8A40-093C3702D748}.Release|Any CPU.Build.0 = Release|Any CPU + {30CD32DF-7134-492E-8F48-BB5A8B473B51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30CD32DF-7134-492E-8F48-BB5A8B473B51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30CD32DF-7134-492E-8F48-BB5A8B473B51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30CD32DF-7134-492E-8F48-BB5A8B473B51}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE