数据结构(Java语言版)实验指导书-绪论实验.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《数据结构(Java语言版)实验指导书-绪论实验.docx》由会员分享,可在线阅读,更多相关《数据结构(Java语言版)实验指导书-绪论实验.docx(2页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、绪论实验答案class Solution/ /存放解int ent;/根个数double xl;double x2;/根2public class 实验 1_2 static Solution solve(double a, double b, double c)/求方程的根Solution s = new Solution ();double d=b*b-4*a*c; if (d 0)s.ent = 0;else if (Math. abs (d) = 0.0001)/等于 0(s.ent = 1;s.xl = (-b + Math.sqrt(d) ) / (2 * a); else s.e
2、nt = 2;s.xl = (-b + Math.sqrt(d) ) / (2 * a);s.x2 = (-b - Math.sqrt(d) / (2 * a); )return s;)static void disp (Solution s)/输出结果if (s.ent = 0)System. out .printin (“无根);else if (s.ent = 1)System.out.printf (4可艮为.Ifnn, s.xl); elseSystem, out: printf (两个根为 .If H%.lfnn, s.xl, s . x2); ) public static vo
3、id main(String args) Solution s;double a = 2, b = -3, c = 4;System. out .printf (n 测试 ln);System.out.printf(na=%.If, b=%.If, c=%.If ”, a, b, c); s = solve(a, b, c);disp(s); a = 1;-2;测试2n”);a=%.lf, b=%.lf, c=%.lf ”, a, b, c);测试3nn);a=%.If, b=%lf, c=%.If ”, a, b, c);c = 1;System.out.printf(Hn System.out.printf( s = solve(a, b, c); disp (s);a = 2;b = -1;c = -1;System.out.printf(n System.out.printf( s = solve(a, b, c);disp(s);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 Java 语言版 实验 指导书 绪论
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内