1
0
forked from kalmar/DALGLI0

Poprawiono nwd

This commit is contained in:
Cezary Baryłka 2018-07-09 07:28:31 +00:00
parent 300097480b
commit 2bc8588fcf
4 changed files with 9 additions and 4 deletions

Binary file not shown.

View File

@ -14,7 +14,9 @@ public class Main {
String multiple = Arrays.toString(PolynomialOperations.multiple(polyF, polyG, modulo));
int[] divisionArray = PolynomialOperations.divide(polyF, polyG, modulo);
String division;
if (divisionArray.length == 0)
if(divisionArray == null)
division = "DivisionError";
else if (divisionArray.length == 0)
division = "[0]";
else
division = Arrays.toString(divisionArray);
@ -22,7 +24,6 @@ public class Main {
if (nwd.equals("null"))
nwd = "DivisionError";
String outputString = "[" + multiple + ", " + division + ", " + nwd + "]";
System.out.println(outputString);
}

Binary file not shown.

View File

@ -55,7 +55,7 @@ public class PolynomialOperations {
public static int[] divide(int[] n, int[] d, int mod) {
if (n.length < d.length) {
throw new IllegalArgumentException("Numerator and denominator vectors must have the same size");
return null;
}
int nd = n.length - 1;
int dd = d.length - 1;
@ -79,7 +79,11 @@ public class PolynomialOperations {
return null;
while (b.length != 0) {
int[] c = divide(a, b, mod);
int[] c;
if (a.length >= b.length)
c = divide(a, b, mod);
else
c = divide(b, a, mod);
a = b;
b = c;
}