gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Primeri koriscenja PolinomL klase
authorDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:17:19 +0000 (13:17 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:17:19 +0000 (13:17 +0200)
kodovi/polinomi/PolSuma.java [new file with mode: 0644]
kodovi/polinomi/PolinomDemo.java [new file with mode: 0644]

diff --git a/kodovi/polinomi/PolSuma.java b/kodovi/polinomi/PolSuma.java
new file mode 100644 (file)
index 0000000..021ec13
--- /dev/null
@@ -0,0 +1,41 @@
+/**\r
+ * Program koji ucitava broj `k`, a potom i niz od `k` polinoma i nakon toga\r
+ * izracunava njihovu sumu.\r
+ */\r
+public class PolSuma {\r
+\r
+       public static void main(String[] args) {\r
+\r
+               int k;\r
+\r
+               do {\r
+                       System.out.print("Unesite broj k ( >0 ) ");\r
+                       k = Svetovid.in.readInt();\r
+               } while (1 > k);\r
+\r
+               PolinomL[] p = new PolinomL[k];\r
+\r
+               for (int i = 0; i < k; i++) {\r
+                       System.out.println();\r
+                       System.out.print("Unos ");\r
+                       System.out.print(i + 1);\r
+                       System.out.print(". polinoma.");\r
+                       System.out.println();\r
+                       p[i] = new PolinomL();\r
+                       p[i].unos();\r
+               }\r
+\r
+               for (int i = 1; i <= k; i++) {\r
+                       System.out.println((i + 1) + ". polinom: "+p[i]);\r
+               }\r
+\r
+               PolinomL suma = new PolinomL();\r
+               for (int i = 1; i <= k; i++) {\r
+                       suma.saberiNa(p[i]);\r
+               }\r
+\r
+               System.out.println();\r
+               System.out.println("Njihova suma je: " + suma);\r
+       }\r
+\r
+}\r
diff --git a/kodovi/polinomi/PolinomDemo.java b/kodovi/polinomi/PolinomDemo.java
new file mode 100644 (file)
index 0000000..d4c7fee
--- /dev/null
@@ -0,0 +1,37 @@
+\r
+public class PolinomDemo {\r
+       \r
+       public static void main(String[] args){\r
+               \r
+               PolinomL p, q, rez;\r
+               \r
+               /*Korisnik unosi prvi polinom*/\r
+               p = new PolinomL();\r
+               System.out.println("Unestite polinom: ");\r
+               p.unos();\r
+               \r
+               /*Drugi polinom kreiramo mi, monom po monom*/\r
+               q = new PolinomL();\r
+               /*Postavimo clan x^5*/\r
+               q.postaviClan(1.0, 5);\r
+               /*-3 x^4*/\r
+               q.postaviClan(-3.0, 4);\r
+               /*4 x*/\r
+               q.postaviClan(4.0, 1);\r
+               /*7 x^0*/\r
+               q.postaviClan(7.0, 0);\r
+               \r
+               /*Sabiramo polinome*/\r
+               rez = p.saberi(q);\r
+               \r
+               /*Odstampamo rezultat i polinome*/\r
+               System.out.println("p: " + p);\r
+               System.out.println();\r
+               System.out.println("q: " + q);\r
+               System.out.println();\r
+               System.out.println("rez: " + rez);\r
+               System.out.println();\r
+               \r
+       }\r
+\r
+}\r
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner