Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2013-06-20T08:49:21+00:00 → 2013-06-21T10:52:57+00:00
<language>Java</language> | |
<code id="51c2bb567eadd" hidden> | |
int z1 = 1; int n1 = 1; | |
int z2 = 1; int n2 = 1; | |
int ze = 1; int ne = 1; | |
public void Bruch1(int z, int n) { | |
if (n < 0) { | |
z = -z; n = Math.abs(n); | |
} | |
z1 = z; | |
n1 = n; | |
} | |
public void Bruch2(int z, int n) { | |
if (n < 0) { | |
z = -z; n = Math.abs(n); | |
} | |
z2 = z; | |
n2 = n; | |
} | |
public void Ausgabe() { | |
System.out.println(ze + "/" + ne); | |
} | |
private int ggT(int m, int n) { | |
if (n == 0) | |
return m; | |
else | |
return ggT(n, m % n); | |
} | |
public void Kuerzen(int z, int n) { | |
int teiler = Math.abs(ggT(z, n)); | |
ze = z / teiler; | |
ne = n / teiler; | |
} | |
</code> | |
| + | == Definition von Brüchen == |
| + | |
<p>Gegeben sind die beiden Brüche <math>b_1=\frac{z_1}{n_1}</math> und <math>b_2=\frac{z_2}{n_2}</math></p> | |
<p>mit <math>z_1, z_2 \in \mathbb{Z}</math> ; <math>n_1, n_2 \in \mathbb{N}</math> und <math>n_1 \not= 0</math> ; <math>n_2 \not= 0</math>.</p> | |
== Addition und Subtraktion von Brüchen == | |
<table border="0" cellpadding="4"> | |
<tr> | |
<td colspan="2">Allgemein gilt:</td> | |
</tr> | |
<tr> | |
| − | <th>Addition</th><th>Subtraktion</th> |
| + | <th><h3>Addition</h3></th><th><h3>Subtraktion</h3></th> |
</tr> | |
<tr valign="top"> | |
<td> | |
<blockquote><math>b_1 + b_2 = \frac{z_1}{n_1} + \frac{z_2}{n_2}</math></blockquote> | |
<blockquote><math>b_1 + b_2 = \frac{z_1 \cdot n_2 + z_2 \cdot n_1}{n_1 \cdot n_2}</math></blockquote> | |
</td> | |
<td> | |
<blockquote><math>b_1 - b_2 = \frac{z_1}{n_1} - \frac{z_2}{n_2}</math></blockquote> | |
<blockquote><math>b_1 - b_2 = \frac{z_1 \cdot n_2 - z_2 \cdot n_1}{n_1 \cdot n_2}</math></blockquote> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2">Natürlich wird das Ergebnis anschließend vollständig gekürzt.</td> | |
</tr> | |
<tr valign="top"> | |
<td> | |
<code id="51c2bb567eb74"> | |
public void Addition() { | |
ze = z1 * n2 + z2 * n1; | |
ne = n1 * n2; | |
Kuerzen(ze, ne); | |
} | |
</code> | |
</td> | |
<td> | |
<code id="51c2bb567ec04"> | |
public void Subtraktion() { | |
ze = z1 * n2 - z2 * n1; | |
ne = n1 * n2; | |
Kuerzen(ze, ne); | |
} | |
</code> | |
</td> | |
</tr> | |
<tr valign="top"> | |
<td> | |
<run id="51c21b59ddc72"> | |
Bruch1(3, 4); | |
Bruch2(2, 3); | |
Addition(); | |
Ausgabe(); | |
</run> | |
</td> | |
<td> | |
<run id="51c2bb567edd0"> | |
Bruch1(3, 4); | |
Bruch2(2, 3); | |
Subtraktion(); | |
Ausgabe(); | |
</run> | |
</td> | |
</tr> | |
</table> | |
== Multiplikation und Division von Brüchen == | |
<table border="0" cellpadding="4"> | |
<tr> | |
<td colspan="2">Allgemein gilt:</td> | |
</tr> | |
<tr> | |
| − | <th>Multiplikation</th><th>Division</th> |
| + | <th><h3>Multiplikation</h3></th><th><h3>Division</h3></th> |
</tr> | |
<tr valign="top"> | |
<td> | |
<blockquote><math>b_1 \cdot b_2 = \frac{z_1}{n_1} \cdot \frac{z_2}{n_2}</math></blockquote> | |
<blockquote><math>b_1 \cdot b_2 = \frac{z_1 \cdot z_2}{n_1 \cdot n_2}</math></blockquote> | |
</td> | |
<td> | |
<blockquote><math>b_1 : b_2 = \frac{z_1}{n_1} : \frac{z_2}{n_2}</math></blockquote> | |
<blockquote><math>b_1 : b_2 = \frac{z_1 \cdot n_2}{n_1 \cdot z_2}</math></blockquote> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2">Auch hier wird das Ergebnis vollständig gekürzt.</td> | |
</tr> | |
<tr valign="top"> | |
<td> | |
<code id="51c2bb567ec84"> | |
public void Multiplikation() { | |
ze = z1 * z2; | |
ne = n1 * n2; | |
Kuerzen(ze, ne); | |
} | |
</code> | |
</td> | |
<td> | |
<code id="51c2bb567ed08"> | |
public void Division() { | |
ze = z1 * n2; | |
ne = n1 * z2; | |
if (ne < 0) { | |
ze = -ze; ne = Math.abs(ne); | |
} | |
Kuerzen(ze, ne); | |
} | |
</code> | |
</td> | |
</tr> | |
<tr valign="top"> | |
<td> | |
<run id="51c2bb567ee60"> | |
Bruch1(3, 4); | |
Bruch2(2, 3); | |
Multiplikation(); | |
Ausgabe(); | |
</run> | |
</td> | |
<td> | |
<run id="51c2bb567eee6"> | |
Bruch1(3, 4); | |
Bruch2(2, 3); | |
Division(); | |
Ausgabe(); | |
</run> | |
</td> | |
</tr> | |
</table> |