Commit 7c216bcf authored by Uwe Wienkop's avatar Uwe Wienkop

Dreistellige Zahlen, Primzahlen mit Stopuhr

parent 0881f9af
<?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>{6B3485E2-B9A3-4CB4-A19A-29D330291976}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_02DreistelligeZahlen2</RootNamespace>
<AssemblyName>02DreistelligeZahlen2</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 _02DreistelligeZahlen2
{
class Program
{
static void Main(string[] args)
{
for (int zahl = 100; zahl < 1000; zahl++)
{
int h = zahl / 100;
int z = zahl % 100 / 10;
int e = zahl % 10;
if (z != 0 && e != 0 &&
zahl % h == 0 && zahl % z == 0 && zahl % e == 0)
Console.Write($"{zahl} ");
}
}
}
}
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("02DreistelligeZahlen2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("02DreistelligeZahlen2")]
[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("6b3485e2-b9a3-4cb4-a19a-29d330291976")]
// 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,7 +11,8 @@ namespace _02Primzahlen
//https://git.informatik.fh-nuernberg.de/Wienkop/Prog1_WS2017_18_Wienkop
static void Main(string[] args)
{
for (int zahl = 2; zahl < 10000; zahl++)
DateTime t0 = DateTime.Now;
for (int zahl = 2; zahl < 1000; zahl++)
{
//Console.WriteLine("Teilertest beginnt");
bool istPrimzahl = true;
......@@ -24,8 +25,8 @@ namespace _02Primzahlen
istPrimzahl = false;
break;
}
else
istPrimzahl = true;
//else // Gefahr!!! Flag-Variable nicht zurücksetzen!!!
// istPrimzahl = true;
}
// Zwei Fälle:
// 1) Die Schleife wird vollständig durchlaufen --> Es ist eine Primzahl
......@@ -37,6 +38,8 @@ namespace _02Primzahlen
//else
// Console.WriteLine($"{zahl} ist KEINE Primzahl");
}
Console.WriteLine();
Console.WriteLine($"Laufzeit: {(DateTime.Now - t0).TotalMilliseconds }");
}
}
}
......@@ -18,12 +18,21 @@ namespace _03Praktikumstipps
Console.WriteLine("Bitte int-Wert für b eingeben");
b = Convert.ToInt32(Console.ReadLine());
// Standardfehlerfälle abtesten
if (a == 0 && b == 0 && c == 0)
Console.WriteLine("Immer wahr");
else if (a == 0 && b == 0 && c != 0)
Console.WriteLine("Keine Lösung");
else if (a == 0 && b != 0)
{
// Lösung für lineare Gleichung
double x = -c / (double)b;
Console.WriteLine($"Lösung x = {x}");
}
else
{
// Quadratische Gleichung per Mitternachtsformel lösen
}
}
}
......
......@@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02DreistelligeZahlen", "02D
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02Praktikumstipps", "03Praktikumstipps\02Praktikumstipps.csproj", "{BDA1AEF1-E1B8-4A76-B055-22E0A5C91594}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02DreistelligeZahlen2", "02DreistelligeZahlen2\02DreistelligeZahlen2.csproj", "{6B3485E2-B9A3-4CB4-A19A-29D330291976}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -56,6 +58,10 @@ Global
{BDA1AEF1-E1B8-4A76-B055-22E0A5C91594}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDA1AEF1-E1B8-4A76-B055-22E0A5C91594}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDA1AEF1-E1B8-4A76-B055-22E0A5C91594}.Release|Any CPU.Build.0 = Release|Any CPU
{6B3485E2-B9A3-4CB4-A19A-29D330291976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B3485E2-B9A3-4CB4-A19A-29D330291976}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B3485E2-B9A3-4CB4-A19A-29D330291976}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B3485E2-B9A3-4CB4-A19A-29D330291976}.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