<img src="https://img-blog.youkuaiyun.com/20141026123653296?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2VuY2hlbmc2MTE5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
double a, b, c;
Console.WriteLine("请输入a,b,c:");
a = Convert.ToDouble(Console.ReadLine());
b = Convert.ToDouble(Console.ReadLine());
c = Convert.ToDouble(Console.ReadLine());
if (Math.Pow(b, 2) - 4 * a * c >= 0)
{
Console.WriteLine("x1=" + (-b + Math.Sqrt(b * b - 4 * a * c)) / (2 * a));
Console.WriteLine("x1=" + (-b - Math.Sqrt(b * b - 4 * a * c)) / (2 * a));
}
else
{
Console.WriteLine("无解!");
Console.Read();
}
}
}
总结:我学会了编程求一元二次方程,非常有意思。