码迷,mamicode.com
首页 > 其他好文 > 详细

作业2.判断一元二次方向根的情况

时间:2014-12-22 22:38:27      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

 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 }

 

作业2.判断一元二次方向根的情况

标签:

原文地址:http://www.cnblogs.com/viven/p/4178957.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!