Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int a, b, c, delta, x;
  14.             double pzd, x1, x2;
  15.             Console.WriteLine("podaj a");
  16.             a = int.Parse(Console.ReadLine());
  17.             Console.WriteLine("podaj b");
  18.             b = int.Parse(Console.ReadLine());
  19.             Console.WriteLine("podaj c");
  20.             c = int.Parse(Console.ReadLine());
  21.            
  22.             delta = b * b - 4 * a * c;
  23.             pzd = Math.Sqrt(delta);
  24.             Console.WriteLine("delta = {0}", delta);
  25.             if(delta < 0)
  26.             {
  27.                 Console.WriteLine("brak miejsc zerowych");
  28.             }
  29.             if(delta == 0)
  30.             {
  31.                 x = -b / 2 * a;
  32.                 Console.WriteLine("jedno miejsce zerowe {0}", x);
  33.             }
  34.             if (delta > 0)
  35.             {
  36.                 x1 = -b - pzd / 2 * a;
  37.                 x2 = -b + pzd / 2 * a;
  38.                 Console.WriteLine("dwa miejsca zerowe x1={0} x2={1}", x1, x2);
  39.             }
  40.             Console.ReadKey();
  41.  
  42.            
  43.  
  44.  
  45.         }
  46.  
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement