Poprawiono nwd
This commit is contained in:
parent
300097480b
commit
2bc8588fcf
BIN
zad2/Main.class
BIN
zad2/Main.class
Binary file not shown.
@ -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.
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user