Решение квадратных уравнений - VB
Формулировка задачи:
Хелп.. сегодня задали Д/з по информатике, работаем в Visual Studio 2005:
решить квадратные уравнения
a | b | c
----------
0 | 0 | 0
----------
0 | 0 | 1
----------
0 | 2 | 6
----------
1 | 0 | 0
----------
1 | 0 | 25
----------
1 | 0 | -25
----------
1 | 2 | 0
----------
1 | 2 | 3 (или 8) не должно быть корней
----------
1 | 2 | -3
----------
Я в информатике ни бе ни ме, это только 3-ее занятие
Кто-нибудь может помочь с написанием программы?
Решение задачи: «Решение квадратных уравнений»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Text;
namespace Kv.uravnenie
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter a");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter b");
int b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter c");
int c = Convert.ToInt32(Console.ReadLine());
int disk = ((b * b) - (4 * a * c));
Console.WriteLine("diskriminat = {0}", disk);
Console.ReadLine();
double sqrtdisk = Math.Sqrt(disk);
Console.WriteLine("{0}", sqrtdisk);
if (sqrtdisk < 0)
Console.WriteLine("нет решен..");
else
{
double x1 = ((-b + sqrtdisk) / (2 * a));
double x2 = ((-b - sqrtdisk) / (2 * a));
Console.WriteLine("{0} {1}", x1, x2);
}
Console.ReadLine();
}
}
}