一元二次方程

// Copyright (c) 2014软件技术1班
<span style="font-family: Arial, Helvetica, sans-serif;"> // 作    者:A36黄阿德</span></span>
// 完成日期:2014年 10 月 27 日
// 版 本 号:v1.1
//问题描述:编写一个程序,可以解一元二次方程</span>
//输入描述:三个任意数a,b,c 
//程序输出:两个实数x1,x2</span>
</pre><pre name="code" class="csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double x1, x2, a, b,c;
            Console.WriteLine("求ax^2+bx+c=0的解");
            Console.WriteLine("请输入第一个数值");            
            a = Convert.ToInt32(Console.ReadLine());
            Console.Beep();
            Console.WriteLine("请输入第二个数值");
            b = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入第三个数值");
            Console.Beep();
            c=Convert.ToInt32(Console.ReadLine());
            x1 = (-b + Math.Sqrt(b * b - 4 * a * c)) / 2 * a;
            x2 = (-b- Math.Sqrt(b * b - 4 * a * c)) / 2 * a;
            Console.WriteLine("{0}:{1}", x1, x2);
            Console.Beep();
            Console.Read();

                        
        }
    }
}
</pre><pre name="code" class="csharp">
</pre><pre name="code" class="csharp"><img src="https://img-blog.csdn.net/20141027224829000?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGJkMDYxNg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值