Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace zsdfgh
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Clear();
- Console.WriteLine("program oblicza miejsca zerowe według funkcji ax2+b");
- Console.Write("podaj a= ");
- float a = 1;
- float b = 1;
- float c = 1;
- a = float.Parse(Console.ReadLine());
- Console.Write("podaj b= ");
- b = float.Parse(Console.ReadLine());
- Console.Write("podaj c= ");
- c = float.Parse(Console.ReadLine());
- if (a == 0)
- {
- Console.WriteLine("a nie może być równe 0");
- return;
- }
- float delta;
- delta = (b * b) - 4 * a * c;
- Console.Write("delta = " + delta);
- if (delta == 0)
- {
- float x;
- x = -b / (2 * a);
- Console.WriteLine(x);
- }
- if (delta < 0)
- {
- Console.WriteLine("Brak miejsc zerowych");
- }
- if (delta > 0)
- {
- double x1, x2;
- double pierwiastek_delta = Math.Sqrt(delta);
- x1 =( (-b) - (pierwiastek_delta / (2 * a)));
- x2 =( (-b) + (pierwiastek_delta / (2 * a)));
- Console.WriteLine("x1 = " + x1);
- Console.WriteLine("x2 = " + x2);
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment