From 14bd8e6827630617b9d1b8dd8cf6d81813065276 Mon Sep 17 00:00:00 2001 From: Krystian Madra Date: Thu, 28 Jun 2018 00:30:33 +0200 Subject: [PATCH] multiply polynomials --- Main.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Main.java b/Main.java index adab3b2..6d395ba 100644 --- a/Main.java +++ b/Main.java @@ -97,5 +97,42 @@ public class Main { return result; } + + public static LinkedList shiftList(LinkedList p, int places){ + + LinkedList result = new LinkedList(p); + + if(places == 0) { + return result; + } + + for(; places>0; places--) { + result.addFirst(0); + } + return result; + } + + + public static LinkedList polynomialsMultiplication(LinkedList p1, LinkedList p2){ + + // suma dlugosci + int amount = p1.size() + p2.size(); + + // nowy wielomian bedzie dlugosci sumy poteg wyrazow wiodacych obu tablic -1 + LinkedList result = new LinkedList(); + + for(int i=0;i