zoukankan      html  css  js  c++  java
  • 作业2.判断一元二次方向根的情况

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace ConsoleApplication1
     7 {
     8     class Program
     9     {
    10         static void Main(string[] args)
    11         {
    12             //输入
    13             Console.Write("分别输入a,b,c三个数");
    14             string a1 = Console.ReadLine();
    15             string b1 = Console.ReadLine();
    16             string c1 = Console.ReadLine();
    17             int a = Convert.ToInt32(a1);
    18             int b = Convert.ToInt32(b1);
    19             int c = Convert.ToInt32(c1);
    20 
    21             if (a == 0)
    22             {
    23                 Console.WriteLine("不是一元二次方程");
    24             }
    25             else
    26             {
    27                 int d = b * b - 4 * a * c;
    28                 if (d < 0)
    29                 {
    30                     Console.WriteLine("一元二次方程无实根");
    31                 }
    32                 else if (d == 0)
    33                 {
    34                     Console.WriteLine("一元二次方程有两个相同实根");
    35                 }
    36                 else
    37                 {
    38                     Console.WriteLine("一元二次方程有两个不同实");
    39                 }
    40             }
    41 
    42         }
    43     }
    44 }
  • 相关阅读:
    关系运算符重载
    一元运算符重载
    二元运算符重载
    重载函数和重载运算符
    Linux之文件通信
    Linux进程通信之mmap
    Linux之创建多个子进程
    内联函数
    静态成员
    this指针
  • 原文地址:https://www.cnblogs.com/viven/p/4178957.html
Copyright © 2011-2022 走看看