Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace równaniekwa
- {
- class Program
- {
- static void Main(string[] args)
- {
- Double a, b, c, d, x1, x2, p, q;
- Console.WriteLine("Wprowadź a:");
- a = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Wprowadź b:");
- b = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Wprowadź c:");
- c = Convert.ToInt32(Console.ReadLine());
- d = Math.Pow(b,2) - (4 * a * c);
- p = (x1 + x2) / 2;
- q = -d / (4 * a);
- if (d == 0)
- {
- Console.Write("Delta rowan zero\n");
- x1 = -b / (2.0 * a);
- x2 = x1;
- Console.Write("Pierwsza wartosc= {0}\n", x1);
- Console.Write("Druga wartosc= {0}\n", x2);
- }
- else if (d > 0)
- {
- Console.Write("Delta wieksza od zera\n");
- x1 = (-b + Math.Sqrt(d)) / (2 * a);
- x2 = (-b - Math.Sqrt(d)) / (2 * a);
- Console.Write("Pierwsza wartosc= {0}\n", x1);
- Console.Write("Druga wartosc= {0}\n", x2);
- }
- else
- Console.Write("Delta mniejsza od zera.\n Brak rozwiazan. \n\n");
- //Iloczynowa
- if (x1>0&&x2>0)
- {
- Console.WriteLine("y=" + a + "(x-" + x1 + ")(x-" + x2 + ")");
- }
- else if (x1<0&&x2>0)
- {
- Console.WriteLine("y=" + a + "(x+" + x1 + ")(x-" + x2 + ")");
- }
- else if (x1 > 0 && x2 < 0)
- {
- Console.WriteLine("y=" + a + "(x-" + x1 + ")(x+" + x2 + ")");
- }
- else
- Console.WriteLine("y=" + a + "(x+" + x1 + ")(x+" + x2 + ")");
- //Kanoniczna
- if (p>0&&q>0)
- {
- Console.WriteLine("y=" + a + "(x-" + p + ")^2+" + q);
- }
- else if (p < 0 && q > 0)
- {
- Console.WriteLine("y=" + a + "(x+" + p + ")^2+" + q);
- }
- else if (p < 0 && q < 0)
- {
- Console.WriteLine("y=" + a + "(x+" + p + ")^2-" + q);
- }
- else
- Console.WriteLine("y=" + a + "(x-" + p + ")^2-" + q);
- Console.WriteLine("p: " + p + " q: " + q);
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement