作业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 }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步