• 利用if else 判断方程有几个根


    static void Main(string[] args)
            {
                 Console.ForegroundColor = ConsoleColor.Green;
                Console.Clear();
                while (true)
                {

                    Console.WriteLine("求方程式ax²+bx=c=0的根的情况");
                    double a, b, c, d; string e;
                    Console.WriteLine("请输入a:");
                    a = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("请输入b:");
                    b = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("请输入c:");
                    c = Convert.ToDouble(Console.ReadLine());
                    if (a > 0||a<0)
                    {
                        Console.WriteLine("方程为一元二次方程");

                        d = b * b - 4 * a * c;
                        Console.WriteLine("形成的德尔塔为" + d);
                        if (d > 0)
                        {
                            Console.WriteLine("方程有两个根");
                        }
                        else if (d == 0)
                        {
                            Console.WriteLine("方程有一个根");
                        }
                        else
                        {
                            Console.WriteLine("方程无解");

                        }

                    }
                    else
                    {
                        Console.WriteLine("方程不是一元二次方程");
                    }

                    Console.ReadLine();


                }
            }
        }

  • 相关阅读:
    angularjs---select使用---默认值及联动
    protobuf--嵌套repeated get set
    protobuf--repeated get set
    Spring学习笔记1——基础知识
    Spring的BeanFactoryPostProcessor和BeanPostProcessor
    Git分支管理策略
    如何高效利用 GitHub
    一张思维导图教你使用google一下
    手把手教你如何加入到github的开源世界
    Spring4 MVC HelloWorld 注解和JavaConfig实例
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374281.html
Copyright © 2020-2023  润新知