Skip to content
Snippets Groups Projects
Commit ee41401e authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

2021-10-25

parent 912d23a8
No related branches found
No related tags found
No related merge requests found
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_04_Do_While_Schleife</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _04_Do_While_Schleife
{
class Program
{
static void Main(string[] args)
{
bool falscheEingabe;
int zahl;
do
{
Console.Write("Geben Sie eine Zahl zwischen 10..20 ein: ");
zahl = Convert.ToInt32(Console.ReadLine());
falscheEingabe = zahl < 10 || zahl > 20;
if (falscheEingabe)
Console.WriteLine("Falsche Eingabe! Nur Zahlen von 10..20!");
} while (falscheEingabe);
//////////////////////////////////////////////////////////
/// Alternativ mit break
do
{
Console.Write("Geben Sie eine Zahl zwischen 10..20 ein: ");
zahl = Convert.ToInt32(Console.ReadLine());
if (zahl >= 10 && zahl <= 20)
break;
Console.WriteLine("Falsche Eingabe! Nur Zahlen von 10..20!");
} while (true);
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_04_Dreiecke_Mo_Ubg</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _04_Dreiecke_Mo_Ubg
{
class Program
{
static void Quadrat(int n)
{
for (int zeile = 1; zeile <= n; zeile++)
{
for (int spalte = 0; spalte < n; spalte++)
{
Console.Write("X");
}
Console.WriteLine();
}
}
static void Dreieck(int n)
{
for (int zeile = 1; zeile <= n; zeile++)
{
for (int spalte = 0; spalte < zeile; spalte++)
{
Console.Write("X");
}
Console.WriteLine();
}
}
static void SinPlot()
{
for (double x = 0.0; x < 2*Math.PI; x+=0.1)
{
int anzLeerzeichen = (int)((Math.Sin(x)+1.0)*30.0);
for (int spalte = 0; spalte < anzLeerzeichen; spalte++)
{
Console.Write(".");
}
Console.WriteLine("*");
}
}
static void Main(string[] args)
{
Quadrat(4);
Dreieck(15);
SinPlot();
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_04_IntroFunktionen</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _04_IntroFunktionen
{
class Program
{
// Funktionen ...
// ... kapseln eine Funktionalität (Einfaches Debugging)
// ... unterteilen eine größere Funktionalität in mehrere kleinere
// ... haben lokale Variablen (keine Namenskonflikte mit etwaig gleichlautenden Variablen aus Main)
// Auch die Parametervariablen sind lokale Variable
// ... liefern einen Return-Wert (void = kein Returnwert)
// Eine Funktion kann mehrere return-Anweisungen haben! return beendet die Funktion sofort!
static bool Primzahltest(int zahl)
{
if (zahl % 2 == 0)
return false;
int teilergrenze = (int)Math.Sqrt(zahl);
for (int teiler = 3; /* n == 0 && */ teiler <= teilergrenze; teiler += 2)
{
if (zahl % teiler == 0)
return false;
}
return true;
}
static void dings(int zahl)
{
int xy = 123;
}
static int incr(int zahl)
{
zahl++;
return zahl;
}
static double kreisflaeche(double r) => Math.PI * r * r;
static void Main(string[] args)
{
bool zahlIstPrimzahl = false;
int zahl = 11;
for (int i = 3; i < 25; i++)
{
Console.WriteLine($"{i,4} --> Primzahl={Primzahltest(i)}");
}
//dings();
Console.WriteLine(zahlIstPrimzahl);
zahl = incr(Convert.ToInt32(Console.ReadLine()));
Console.WriteLine(zahl*zahl);
Console.WriteLine(kreisflaeche(1.5));
Console.WriteLine(kreisflaeche(Convert.ToDouble(Console.ReadLine())));
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_04_Schachbrett</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _04_Schachbrett
{
class Program
{
static void Main(string[] args)
{
bool schwarz = true;
string schwarzFeld = "XXXXX";
string weissFeld = " ";
for (int z = 0; z < 8; z++)
{
for (int n = 0; n < 3; n++)
{
for (int s = 0; s < 8; s++)
{
if (schwarz)
Console.Write(schwarzFeld);
else
Console.Write(weissFeld);
schwarz = !schwarz;
}
Console.WriteLine();
}
schwarz = !schwarz;
}
}
}
}
...@@ -15,17 +15,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02 Ausgabeformatierung", "0 ...@@ -15,17 +15,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02 Ausgabeformatierung", "0
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02 Fallunterscheidungen", "02 Fallunterscheidungen\02 Fallunterscheidungen.csproj", "{3370BE4E-7EF8-4ABB-949D-62CA9FA5CDA7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02 Fallunterscheidungen", "02 Fallunterscheidungen\02 Fallunterscheidungen.csproj", "{3370BE4E-7EF8-4ABB-949D-62CA9FA5CDA7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 SchleifenIntro", "03 SchleifenIntro\03 SchleifenIntro.csproj", "{5C715673-820D-4FC5-B8C6-EEE0890713EE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 SchleifenIntro", "03 SchleifenIntro\03 SchleifenIntro.csproj", "{5C715673-820D-4FC5-B8C6-EEE0890713EE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 Primzahltest", "03 Primzahltest\03 Primzahltest.csproj", "{958EC31B-7CFC-470B-87AD-2AEB00E816A5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 Primzahltest", "03 Primzahltest\03 Primzahltest.csproj", "{958EC31B-7CFC-470B-87AD-2AEB00E816A5}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 IntArithmetik", "03 IntArithmetik\03 IntArithmetik.csproj", "{9CB8537D-D35E-4718-9258-12857B8B7411}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 IntArithmetik", "03 IntArithmetik\03 IntArithmetik.csproj", "{9CB8537D-D35E-4718-9258-12857B8B7411}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 IntArithmetik_Di", "03 IntArithmetik_Di\03 IntArithmetik_Di.csproj", "{EADEA381-506F-41FF-99EC-487D4D3B6114}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 IntArithmetik_Di", "03 IntArithmetik_Di\03 IntArithmetik_Di.csproj", "{EADEA381-506F-41FF-99EC-487D4D3B6114}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 Quersumme", "03 Quersumme\03 Quersumme.csproj", "{C2D51C5D-AFDC-4A8A-9393-904A1CAA2CCC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 Quersumme", "03 Quersumme\03 Quersumme.csproj", "{C2D51C5D-AFDC-4A8A-9393-904A1CAA2CCC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03 Quadratzahlen_bis", "03 Quadratzahlen_bis\03 Quadratzahlen_bis.csproj", "{F492AB76-864B-45FD-9BF2-36B9CA24987D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03 Quadratzahlen_bis", "03 Quadratzahlen_bis\03 Quadratzahlen_bis.csproj", "{F492AB76-864B-45FD-9BF2-36B9CA24987D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 Schachbrett", "04 Schachbrett\04 Schachbrett.csproj", "{4C1097BC-5773-43BA-A40E-DF2E66BFCE81}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 Do_While_Schleife", "04 Do_While_Schleife\04 Do_While_Schleife.csproj", "{C208A9CA-81BF-4514-ABD7-107162940C1E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04 IntroFunktionen", "04 IntroFunktionen\04 IntroFunktionen.csproj", "{B22C3D1C-0375-451F-885F-51015FE6633C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04 Dreiecke_Mo_Ubg", "04 Dreiecke_Mo_Ubg\04 Dreiecke_Mo_Ubg.csproj", "{40E4407D-F055-463C-96E6-63F948EF19E7}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -81,6 +89,22 @@ Global ...@@ -81,6 +89,22 @@ Global
{F492AB76-864B-45FD-9BF2-36B9CA24987D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F492AB76-864B-45FD-9BF2-36B9CA24987D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F492AB76-864B-45FD-9BF2-36B9CA24987D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F492AB76-864B-45FD-9BF2-36B9CA24987D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F492AB76-864B-45FD-9BF2-36B9CA24987D}.Release|Any CPU.Build.0 = Release|Any CPU {F492AB76-864B-45FD-9BF2-36B9CA24987D}.Release|Any CPU.Build.0 = Release|Any CPU
{4C1097BC-5773-43BA-A40E-DF2E66BFCE81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C1097BC-5773-43BA-A40E-DF2E66BFCE81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C1097BC-5773-43BA-A40E-DF2E66BFCE81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C1097BC-5773-43BA-A40E-DF2E66BFCE81}.Release|Any CPU.Build.0 = Release|Any CPU
{C208A9CA-81BF-4514-ABD7-107162940C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C208A9CA-81BF-4514-ABD7-107162940C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C208A9CA-81BF-4514-ABD7-107162940C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C208A9CA-81BF-4514-ABD7-107162940C1E}.Release|Any CPU.Build.0 = Release|Any CPU
{B22C3D1C-0375-451F-885F-51015FE6633C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B22C3D1C-0375-451F-885F-51015FE6633C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B22C3D1C-0375-451F-885F-51015FE6633C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B22C3D1C-0375-451F-885F-51015FE6633C}.Release|Any CPU.Build.0 = Release|Any CPU
{40E4407D-F055-463C-96E6-63F948EF19E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40E4407D-F055-463C-96E6-63F948EF19E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40E4407D-F055-463C-96E6-63F948EF19E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40E4407D-F055-463C-96E6-63F948EF19E7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment