Commit 827b69d0 authored by Uwe Wienkop's avatar Uwe Wienkop

Updates

parent 219b469c
......@@ -20,6 +20,11 @@ namespace _03Funktionen
Console.WriteLine(x);
}
/// <summary>
/// Liefert das Quadrat seines Parameters
/// </summary>
/// <param name="x">Eingangsparameter</param>
/// <returns>Das Quadrat von x</returns>
static int Quadriere(int x)
// int Quadriere --> Quadriere liefert ein int-Ergebnis
// int x --> Eingangsparameter, hier vom Typ int
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{43B32ACD-F4F8-4A01-B3AB-3287676C518A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_06GameOfLife_Console</RootNamespace>
<AssemblyName>06GameOfLife_Console</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _06GameOfLife_Console
{
class GameOfLife
{
const int feldgroesse = 30; // Größe der Welt: feldgroesse x feldgroesse
const int verzoegerung = 250; // Millisekunden
/// <summary>
/// Zeigt eine Generation an der Console an
/// </summary>
/// <param name="gen">aktuelle Generation</param>
static void Anzeigen(bool[,] gen)
{
// Fensterinhalt löschen (d. h. wir fangen wieder oben links an):
Console.Clear();
// Elemente zeilenweise ausgeben:
for (int i = 0; i < gen.GetLength(0); i++)
{
for (int j = 0; j < gen.GetLength(1); j++)
{
if (gen[i, j]) // Entspricht: gen[i,j]==true?)
Console.Write("#");
else
Console.Write(".");
}
Console.WriteLine();
}
}
/// <summary>
/// Erzeugt eine neue Startgeneration
/// </summary>
/// <returns>Generation; bool[,] Feld</returns>
static bool[,] BigBang()
{
bool[,] gen = new bool[feldgroesse, feldgroesse];// neues Feld, Größe: feldgroesse x feldgroesse
// Zufällig mit lebenden Zellen füllen:
// Verwende ein Random-Objekt
Random R = new Random();
// Wähle zufällig die Anzahl der lebenden Zellen, z. B.:
// int anzElemente = R.Next(1, feldgroesse * feldgroesse);
// for i = 1 ... anzElemente
// wähle zufällige "Koordinaten": R.Next(0, feldgroesse)
// jeweils für Zeile und Spalte und setze gen an diesen Koordinaten = true
/////////////////////////////////////////////////////////////////////////
// 2 Interessante Startmuster zum Ausprobieren
// Einfach entsprechend ein-/auskommentieren
// Gleiter:
//int Smax = gen.GetLength(1);
//gen[13, Smax - 10] = true;
//gen[14, Smax - 11] = true;
//gen[14, Smax - 12] = true;
//gen[13, Smax - 12] = true;
//gen[12, Smax - 12] = true;
// 42:
gen[10, 10] = gen[10, 12] = gen[10, 15] = gen[10, 16] = gen[10, 17] = true;
gen[11, 10] = gen[11, 12] = gen[11, 17] = true;
gen[12, 10] = gen[12, 11] = gen[12, 12] = gen[12, 15] = gen[12, 16] = gen[12, 17] = true;
gen[13, 12] = gen[13, 15] = true;
gen[14, 12] = gen[14, 15] = gen[14, 16] = gen[14, 17] = true;
//////////////////////////////////////////////////////////////////////////////////////////
return gen;
}
/// <summary>
/// Ermittelt für jede Zelle die Anzahl ihrer lebenden Nachbarn
/// </summary>
/// <param name="generation">aktuelle Generation</param>
/// <returns>neues Feld, enthält die ermittelten Werte</returns>
//static int[,] AnzahlNachbarn(bool[,] generation)
//{
// // anzN = neues int[,] Feld, gleiche Größe wie der Parameter "generation"
// // Für jedes Element in generation:
// // falls Element lebendig
// // Nachbarn in anzN erhöhen ... siehe Aufgabenstellung!
// // return anzN;
//}
/// <summary>
/// Evolutionsschritt gemäß Conways Regeln
/// </summary>
/// <param name="generation">aktuelle Generation; wird durch die Funktion verändert</param>
//static void Evolution(bool[,] generation)
//{
// int[,] anzN = AnzahlNachbarn(generation);
// // Your Code here
//}
static void Main(string[] args)
{
// Startmuster:
bool[,] generation = BigBang();
// Simulation:
//while (true)
//{
Anzeigen(generation);
System.Threading.Thread.Sleep(20); // Damit's nicht zu schnell geht
//// Alternativ: Manuell weiterschalten
//// Console.ReadKey();
//Evolution(generation);
//}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("06GameOfLife_Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("06GameOfLife_Console")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("43b32acd-f4f8-4a01-b3ab-3287676c518a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{04332BC2-510F-422F-808E-4AD9366DC255}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_06Zufallsgütetest</RootNamespace>
<AssemblyName>06Zufallsgütetest</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _06Zufallsgütetest
{
class Program
{
static void Main(string[] args)
{
int[] anzahlen = new int[20];
Random R = new Random();
for (int i = 0; i < 10000; i++)
{
int gewuerfelt = R.Next(0, 20);
// anzahlen[gewuerfelt] = anzahlen[gewuerfelt] + 1; -- Richtig
anzahlen[R.Next(0, 20)] = anzahlen[R.Next(0, 20)] +1; //-- Völlig falsch
// anzahlen[R.Next(0,20)]+=1; -- richtig
// anzahlen[R.Next(0,20)]++; -- richtig
}
for (int i = 0; i < anzahlen.Length; i++)
{
Console.Write($" | {anzahlen[i],4} {anzahlen[i]/100.0,5:f0}%");
}
Console.WriteLine();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("06Zufallsgütetest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("06Zufallsgütetest")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("04332bc2-510f-422f-808e-4ad9366dc255")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
......@@ -11,25 +11,38 @@ namespace _06ZweidimFelder
static void Main(string[] args)
{
int[] f = new int[5];
int[,] f2 = new int[7, 7];
const int AnzZeilen = 12;
const int AnzSpalten = 8;
int[,] f2 = new int[AnzZeilen, AnzSpalten];
// Initialisieren des 2D-Feldes mit 1
//for (int z = 0; z < 4; z++)
//for (int z = 0; z < 7; z++)
//{
// for (int s = 0; s < 4; s++)
// for (int s = 0; s < 7; s++)
// {
// f2[z, s] = 1;
// }
//}
for (int z = 0; z < 7; z++)
Console.WriteLine($"f[] hat {f.Length} Elemente");
// .Length liefert die Anzahl der Elemente des Feldes
Console.WriteLine($"f2[,] hat {f2.Length} Elemente");
// bei mehrdim. Feldern auch wieder die Gesamtanz.
// der Feldelemente
f2[4, 2] = 123;
f2[1, 3] = 77;
// Ausgeben eines 2D-Feldes
// .GetLength(0) - Anz. der Elemente der 1. Dimension
// .GetLength(1) - entsprechend 2. Dim.
for (int z = 0; z < f2.GetLength(0); z++)
{
for (int s = 0; s < 7; s++)
for (int s = 0; s < f2.GetLength(1); s++)
{
Console.Write($"{f2[z,s],3}"); ;
Console.Write($"{f2[z,s],8}");
}
Console.WriteLine();
}
Console.WriteLine("-----------------");
// Vorschläge für Übungen mit 2D-Feldern
// 1) Rahmen
......
......@@ -50,6 +50,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "06MinimumUndSortieren", "06
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "06ZweidimFelder", "06ZweidimFelder\06ZweidimFelder.csproj", "{45A20C47-A99B-49AA-BCD7-4C4E9E193AA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "06Zufallsgütetest", "06Zufallsgütetest\06Zufallsgütetest.csproj", "{04332BC2-510F-422F-808E-4AD9366DC255}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "06GameOfLife_Console", "06GameOfLife_Console\06GameOfLife_Console.csproj", "{43B32ACD-F4F8-4A01-B3AB-3287676C518A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -140,6 +144,14 @@ Global
{45A20C47-A99B-49AA-BCD7-4C4E9E193AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45A20C47-A99B-49AA-BCD7-4C4E9E193AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45A20C47-A99B-49AA-BCD7-4C4E9E193AA6}.Release|Any CPU.Build.0 = Release|Any CPU
{04332BC2-510F-422F-808E-4AD9366DC255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04332BC2-510F-422F-808E-4AD9366DC255}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04332BC2-510F-422F-808E-4AD9366DC255}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04332BC2-510F-422F-808E-4AD9366DC255}.Release|Any CPU.Build.0 = Release|Any CPU
{43B32ACD-F4F8-4A01-B3AB-3287676C518A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43B32ACD-F4F8-4A01-B3AB-3287676C518A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43B32ACD-F4F8-4A01-B3AB-3287676C518A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43B32ACD-F4F8-4A01-B3AB-3287676C518A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment