people

Katsayıları dışarıdan girilen ikinci dereceden bir denklemin çözüm kümesini bulan program.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Soru_Dort
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("a Sayısını Girin");
int a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("b Sayısını Girin");
int b = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("c Sayısını Girin");
int c = Convert.ToInt32(Console.ReadLine());

double _delta = Math.Sqrt(b) - 4 * a * c;

if (_delta < 0)
{
Console.WriteLine("Reel Kök Yok");
}

else if (_delta == 0)
{
double x = (-b) / 2 * a;
Console.WriteLine("x = " + x);
}

else
{
double x1 = (-b) - Math.Sqrt(_delta) / (2 * a);
double x2 = (-b) + Math.Sqrt(_delta) / (2 * a);
Console.WriteLine("x1 = " + x1 + " x2 = " + x2);
}




Console.ReadLine();
}
}
}

0 yorum:

Yorum Gönder