zoukankan      html  css  js  c++  java
  • 09.01,学习习题

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {//判断一个方程是不是一个一元二次方程,并判断解得情况
                Console.WriteLine("a*x*x+b*x+c=0");
                Console.Write("请输入数字a=");
                double a = double.Parse(Console.ReadLine());
                Console.Write("请输入数字b=");
                double b = double.Parse(Console.ReadLine());
                Console.Write("请输入数字c=");
                double c = double.Parse(Console.ReadLine());
                double D = b * b - 4 * a * c;
                if (a == 0)
                {
                    Console.WriteLine("不是一元二次方程");
                }
    
                else
                {
                    Console.WriteLine("是一元二次方程");
                    if (D >= 0)
                    {
                        double x1 = (-b + Math.Sqrt(D)) / (2 * a);
                        double x2 = (-b - Math.Sqrt(D)) / (2 * a);
                        if (D > 0)
                        {
                            Console.WriteLine("方程有两个不相等的实根");
                            Console.WriteLine("x1=" + x1.ToString() + "x1=" + x2.ToString());
                        }
                        else if (D == 0)
                        {
                            Console.WriteLine("方程式有两个相等的实根");
                            Console.WriteLine("x1=x2=" + x1.ToString());
    
                        }
    
                    }
                    else if (D < 0)
                    {
                        Console.WriteLine("方程没有实根");
    
                    }
                    Console.ReadLine();
                }
            }
        }
    }

    2015.09.01今天预习做得习题!!

  • 相关阅读:
    多按键设计的标准思路
    与,非,或门总结
    i2c中应答信号信号总结
    i2c中start和restart的区别
    poj 1631 Bridging signals
    poj 2533 Longest Ordered Subsequence
    poj 1887 Testing the CATCHER
    poj 1088 滑雪
    poj 1014 Dividing
    babel转码时generator的regeneratorRuntime
  • 原文地址:https://www.cnblogs.com/cf924823/p/4776099.html
Copyright © 2011-2022 走看看