< 4)System.out.print("wrong number of points");String[] point3 = dj[2].split(",");String[] point4 = dj[3].split(",");if (!dj[0].equals(dj[1]) && !dj[2].equals(dj[3])) {if (point1.length == 2 && point2.length == 2 && point3.length == 2 && point4.length == 2) {if (legal(point1[0]) && legal(point1[1]) && legal(point2[0]) && legal(point2[1]) && legal(point3[0])&& legal(point3[1]) && legal(point4[0]) && legal(point4[1])) {double x0 = Double.parseDouble(point1[0]);double y0 = Double.parseDouble(point1[1]);double x1 = Double.parseDouble(point2[0]);double y1 = Double.parseDouble(point2[1]);double x2 = Double.parseDouble(point3[0]);double y2 = Double.parseDouble(point3[1]);double x3 = Double.parseDouble(point4[0]);double y3 = Double.parseDouble(point4[1]);if (dj.length == 4 && (y3 - y2) / (x3 - x2) == (y1 - y0) / (x1 - x0))System.out.print("true");if ((y3 - y2) / (x3 - x2) != (y1 - y0) / (x1 - x0))System.out.print("false");if (dj.length > 4)//点数量的判断System.out.print("wrong number of points");} elseSystem.out.print("Wrong Format");} elseSystem.out.print("Wrong Format");} elseSystem.out.print("points coincide");}void Five(String x) {String[] dj = x.split(" ");String[] point1 = dj[0].split(",");String[] point2 = dj[1].split(",");if (dj.length < 4)System.out.print("wrong number of points");String[] point3 = dj[2].split(",");String[] point4 = dj[3].split(",");if (!dj[0].equals(dj[1]) && !dj[2].equals(dj[3])) {if (point1.length == 2 && point2.length == 2 && point3.length == 2 && point4.length == 2) {if (legal(point1[0]) && legal(point1[1]) && legal(point2[0]) && legal(point2[1]) && legal(point3[0])&& legal(point3[1]) && legal(point4[0]) && legal(point4[1])) {double x0 = Double.parseDouble(point1[0]);double y0 = Double.parseDouble(point1[1]);double x1 = Double.parseDouble(point2[0]);double y1 = Double.parseDouble(point2[1]);double x2 = Double.parseDouble(point3[0]);double y2 = Double.parseDouble(point3[1]);double x3 = Double.parseDouble(point4[0]);double y3 = Double.parseDouble(point4[1]);if ((y3 - y2) / (x3 - x2) == (y1 - y0) / (x1 - x0))//线平行的情况System.out.print("is parallel lines,have no intersection point");else {double yz = ((y0 - y1) * (y3 - y2) * x0 + (y3 - y2) * (x1 - x0) * y0//xz,yz为交点坐标+ (y1 - y0) * (y3 - y2) * x2 + (x2 - x3) * (y1 - y0) * y2)/ ((x1 - x0) * (y3 - y2) + (y0 - y1) * (x3 - x2));double xz = x2 + (x3 - x2) * (yz - y2) / (y3 - y2);if (dj.length == 4) {System.out.print(xz + "," + yz + " ");if ((y1 - y0) / (xz - x0) == (yz - y0) / (x1 - x0),|| (y3 - y2) / (xz - x2) == (yz - y2) / (x3 - x2))System.out.print("true");elseSystem.out.print("false");}if (dj.length > 4)System.out.print("wrong number of points");}} elseSystem.out.print("Wrong Format");} elseSystem.out.print("Wrong Format");} elseSystem.out.print("points coincide");}}
第三次作业第三题
7-3 点线形系列3-三角形的计算 (48 分)
用户输入一组选项和数据,进行与三角形有关的计算 。选项包括:
1:输入三个点坐标,判断是否是等腰三角形、等边三角形,判断结果输出true/false,两个结果之间以一个英文空格符分隔 。
2:输入三个点坐标,输出周长、面积、重心坐标,三个参数之间以一个英文空格分隔,坐标之间以英文","分隔 。
3:输入三个点坐标,输出是钝角、直角还是锐角三角形,依次输出三个判断结果(true/false),以一个英文空格分隔,
4:输入五个点坐标,输出前两个点所在的直线与三个点所构成的三角形相交的交点数量,如果交点有两个,则按面积大小依次输出三角形被直线分割成两部分的面积 。若直线与三角形一条线重合,输出"The point is on the edge of the "
5:输入四个点坐标,输出第一个是否在后三个点所构成的三角形的内部(输出in the /outof ) 。
必须使用射线法,原理:由第一个点往任一方向做一射线,射线与三角形的边的交点(不含点本身)数量如果为1,则在三角形内部 。如果交点有两个或0个,则在三角形之外 。若点在三角形的某条边上,输出"on the "
- 一级 2020年06月 Python真题解析#中国电子学会#全国青少年软件编程
- 推荐几个ai聊天软件给大家
- 五 点云深度学习系列博客: 注意力机制原理概述
- 每日一题 pwnable.kr flag
- 为什么你自律一段时间后,还是会被打回原形?
- 二手车贷款利息一般几厘
- 怎么提取视频中的音频?这几种提取音频方法了解一下
- Diffusion Model一发力,GAN就过时了???
- 每天8个小时睡眠够吗 8小时睡眠不一定适合每个人
- 上 数据结构及算法 | Java数据结构——BST二叉搜索树