1
0
forked from kalmar/DALGLI0
DALGLI0/zad2/Main.java

55 lines
1.6 KiB
Java

import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ArrayList<Integer> f = new ArrayList<>();
ArrayList<Integer> g = new ArrayList<>();
int n;
Scanner scanner = new Scanner(System.in);
Polynomial polynomial;
System.out.print("Podaj n: ");
n = scanner.nextInt();
polynomial = new Polynomial(n);
System.out.print("Najwyższa potęga współczynników f: ");
n = scanner.nextInt();
for (int i = 0; i <= n; ++i){
System.out.print("x^" + i + " = ");
f.add(scanner.nextInt());
}
System.out.print("Najwyższa potęga współczynników g: ");
n = scanner.nextInt();
for (int i = 0; i <= n; ++i){
System.out.print("g^" + i + " = ");
g.add(scanner.nextInt());
}
// polynomial = new Polynomial(2);
// f.add(1);
// f.add(1);
// f.add(1);
// f.add(0);
// f.add(1);
//
// g.add(0);
// g.add(1);
// g.add(1);
ArrayList<Integer> result = polynomial.multiply(f, g);
for (Integer i : result){
System.out.print(i + " ");
}
System.out.println();
result = polynomial.divide(f, g);
for (Integer i : result){
System.out.print(i + " ");
}
// System.out.println();
// result = polynomial.nwd(f, g);
// for (Integer i : result){
// System.out.print(i + " ");
// }
}
}