inital commit

This commit is contained in:
Paul 2020-10-18 21:52:01 +02:00
commit 0340ad4620
14 changed files with 231 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="Kapitel2Aufgabe9:jar">
<output-path>$PROJECT_DIR$</output-path>
<root id="archive" name="Kapitel2Aufgabe9.jar">
<element id="module-output" name="Kapitel2Aufgabe9" />
</root>
</artifact>
</component>

1
.idea/description.html generated Normal file
View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

6
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

12
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Kapitel2Aufgabe9.iml" filepath="$PROJECT_DIR$/Kapitel2Aufgabe9.iml" />
</modules>
</component>
</project>

3
.idea/project-template.xml generated Normal file
View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

48
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="48aba5c2-e5ce-44a4-9267-b047c12f9873" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectId" id="1bR6Lh3fBfl949avK521mkKtwju" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="48aba5c2-e5ce-44a4-9267-b047c12f9873" name="Default Changelist" comment="" />
<created>1588582505140</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1588582505140</updated>
<workItem from="1588582508413" duration="49000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="267" y="547" key="com.intellij.ide.util.TipDialog" timestamp="1588582510292">
<screen x="62" y="0" width="1018" height="1920" />
</state>
<state x="267" y="547" key="com.intellij.ide.util.TipDialog/1142.249.3378.1440/62.0.1018.1920/2189.-651.1378.900@62.0.1018.1920" timestamp="1588582510292" />
<state x="1369" y="593" key="new project wizard" timestamp="1588582554383">
<screen x="1142" y="249" width="3378" height="1440" />
</state>
<state x="1369" y="593" key="new project wizard/1142.249.3378.1440/62.0.1018.1920/2189.-651.1378.900@1142.249.3378.1440" timestamp="1588582554383" />
</component>
</project>

12
Kapitel2Aufgabe9.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

BIN
Kapitel2Aufgabe9.jar Normal file

Binary file not shown.

4
Readme.txt Normal file
View File

@ -0,0 +1,4 @@
Name: Paul Lödige
Matrikel Nr.: 15405036
Projekt als ausführbare jar-Datei vorhanden

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: tech.loedige.Main

3
src/META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: tech.loedige.Main

123
src/tech/loedige/Main.java Normal file
View File

@ -0,0 +1,123 @@
package tech.loedige;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
//Persönliche Infos
System.out.format("%-15s","Name:");
System.out.println("Paul Lödige");
System.out.format("%-15s","Matrikel Nr.:");
System.out.println("15405036");
System.out.println();
eea(new BigInteger("3576222"), new BigInteger("117624"));
}
public static void eea(BigInteger a, BigInteger b){
//Auf fehlerhafte Eingabe überprüfen
if(a.compareTo(BigInteger.ZERO)==-0 || b.compareTo(BigInteger.ZERO)==-0){
System.out.println("mind. eine der Eingaben war 0. Hiermit ist der Euklid'sche Algoithmus nicht möglich");
return;
}
//Auf negative Eingabe überprüfen
if(a.compareTo(BigInteger.ZERO)==-1 || b.compareTo(BigInteger.ZERO)==-1){
System.out.println("Die Vorzeichen der Eingabe werden im Folgenden ignoriert.");
}
//Vorzeichen ignorieren
a = a.abs();
b = b.abs();
//Reihenfolge der Eingabewerte sicherstellen
if (a.compareTo(b)==-1){
BigInteger storage = a;
a = b;
b = storage;
}
//Format für ordentliche Einrückung bestimmen
int length = a.toString().length();
String format = "%" + length + "s";
//Header ausgeben
printLine(a.toString(),b.toString(),"","q",format);
for(int i = 0; i<length * 4 + 12; i++)
System.out.print("-");
System.out.println();
//region Euklid'scher Algorithmus
//Variablen definieren
BigInteger mul_a;
BigInteger mul_a_old;
BigInteger mul_b;
BigInteger mul_b_old;
BigInteger result_old;
BigInteger result;
BigInteger q;
BigInteger storage;
//erste Zeile
mul_a = BigInteger.ONE;
mul_b = BigInteger.ZERO;
result = a;
printLine(mul_a.toString(),mul_b.toString(),result.toString(),"",format);
//zweite Zeile
mul_a_old = mul_a;
mul_b_old = mul_b;
mul_a = BigInteger.ZERO;
mul_b = BigInteger.ONE;
result_old = result;
result = b;
q = result_old.divide(result);
printLine(mul_a.toString(),mul_b.toString(),result.toString(),q.toString(),format);
//Algorithmus
do{
//new result
storage = result;
result = result_old.subtract(result.multiply(q));
result_old = storage;
//new mul_a
storage = mul_a;
mul_a = mul_a_old.subtract(mul_a.multiply(q));
mul_a_old = storage;
//new mul_b
storage = mul_b;
mul_b = mul_b_old.subtract(mul_b.multiply(q));
mul_b_old = storage;
//new q
if(result.compareTo(BigInteger.ZERO)==1)
q = result_old.divide(result);
else
q = null;
//print
printLine(mul_a.toString(),
mul_b.toString(),
result.toString(),
q != null ? q.toString() : "",
format);
}while(result.compareTo(BigInteger.ZERO)==1);
//endregion
}
private static void printLine(String mul_a, String mul_b, String result, String q, String format){
System.out.format(format,mul_a);
System.out.print(" ");
System.out.format(format,mul_b);
System.out.print(" ");
System.out.format(format,result);
System.out.print(" ");
System.out.format(format,q);
System.out.println();
}
}