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 }
时间: 2024-11-05 15:47:03