一、前言
题目集1主要是为了让我们熟悉java的一些基本操作,总体难度不大。题目集2相比题目集1难度难度略高,但目的仍是熟悉java的操作使用。题目集3的难度相比前两个有很大提升,同时也加入了新的方向,即从从过程到对象。
二、设计与分析
7-2 串口字符解析
RS232是串口常用的通信协议,在异步通信模式下,串口可以一次发送5~8位数据,收发双方之间没有数据发送时线路维持高电平,相当于接收方持续收到数据“1”(称为空闲位),发送方有数据发送时,会在有效数据(5~8位,具体位数由通信双方提前设置)前加上1位起始位“0”,在有效数据之后加上1位可选的奇偶校验位和1位结束位“1”。请编写程序,模拟串口接收处理程序,注:假定有效数据是8位,奇偶校验位采用奇校验。
输入格式:
由0、1组成的二进制数据流。例如:11110111010111111001001101111111011111111101111
输出格式:
过滤掉空闲、起始、结束以及奇偶校验位之后的数据,数据之前加上序号和英文冒号。
如有多个数据,每个数据单独一行显示。
若数据不足11位或者输入数据全1没有起始位,则输出"null data",
若某个数据的结束符不为1,则输出“validate error”。
若某个数据奇偶校验错误,则输出“parity check error”。
若数据结束符和奇偶校验均不合格,输出“validate error”。
如:11011或11111111111111111。
例如:
1:11101011
2:01001101
3:validate error
源代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int n = 8;
int m = 0;
int k = 0;
int i;
int l = 1;
int Checkbit = 1;
int Checkjiou = 1;
int Borrowinpo = 1;
String s = input.nextLine();
if(s.length()<11)
{
System.out.print("null data");
return;
}
while(m<s.length())
{
if(s.charAt(m)=='0')
{
k=1;
m++;
String s1 = s.substring(m, m+10);
String s2 = s.substring(m, m+8);
if(Parity(s1,Checkbit)==0)
Checkjiou = 0;
if(s1.charAt(n+1)!='1')
Borrowinpo = 0;
m+=9;
if(Checkjiou==1&&Borrowinpo==1)
{
System.out.println(l+":"+s2);
}
else if(Checkjiou==0&&Borrowinpo==0)
{
System.out.println(l+":"+"validate error");
}
else if(Checkjiou==0)
{
System.out.println(l+":"+"parity check error");
}
else
{
System.out.println(l+":"+"validate error");
}
l++;
Checkjiou = 1;
Borrowinpo = 1;
}
m++;
}
if(k==0)
{
System.out.print("null data");
return;
}
}
public static int Parity(String s,int check)
{
int i;
int sum = 0;
for(i=0;i<s.length()-1;i++)
{
if(s.charAt(i)=='1')
sum++;
}
if(sum%2==check)
return 1;
else return 0;
}
}
7-1 点线形系列1-计算两点之间的距离
输入连个点的坐标,计算两点之间的距离
输入格式:
4个double类型的实数,两个点的x,y坐标,依次是x1、y1、x2、y2,两个点的坐标之间以空格分隔,每个点的x,y坐标以英文“,”分隔。例如:0,0 1,1或0.1,-0.3 +3.5,15.6。
若输入格式非法,输出"Wrong Format"。
若输入格式合法但坐标点的数量超过两个,输出“wrong number of points”。
输出格式:
计算所得的两点之间的距离。例如:1.4142135623730951
源码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s = input.nextLine();
String[] s1 = s.split(" ");
String[] s2;
double x1,x2,y1,y2;
double chang;
for(String i:s1)
{
s2 = i.split(",");
for(String o:s2)
{
if(!(o.matches("^(\\-|\\+)?\\d+(\\.\\d+)?$")||o.matches("^[+-]?[0-9]*$")))
{
System.out.println("Wrong Format");
return;
}
}
}
if(s1.length>2)
{
System.out.println("wrong number of points");
return;
}
String i = s1[0];
s2 = i.split(",");
x1 = Double.valueOf(s2[0]);
y1 = Double.valueOf(s2[1]);
i = s1[1];
s2 = i.split(",");
x2 = Double.valueOf(s2[0]);
y2 = Double.valueOf(s2[1]);
chang = Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
System.out.println(chang);
}
}
7-2 点线形系列2-线的计算
用户输入一组选项和数据,进行与直线有关的计算。选项包括:
1:输入两点坐标,计算斜率,若线条垂直于X轴,输出"Slope does not exist"。
2:输入三个点坐标,输出第一个点与另外两点连线的垂直距离。
3:输入三个点坐标,判断三个点是否在一条线上,输出true或者false。
4:输入四个点坐标,判断前两个点所构成的直线与后两点构成的直线是否平行,输出true或者false.
5:输入四个点坐标,计算输出前两个点所构成的直线与后两点构成的直线的交点坐标,x、y坐标之间以英文分隔",",并输出交叉点是否在两条线段之内(不含四个端点)的判断结果(true/false),判断结果与坐标之间以一个英文空格分隔。若两条线平行,没有交叉点,则输出"is parallel lines,have no intersection point"。
输入格式:
基本格式:选项+":"+坐标x+","+坐标y+" "+坐标x+","+坐标y。
例如:1:0,0 1,1
如果不符合基本格式,输出"Wrong Format"。
如果符合基本格式,但输入点的数量不符合要求,输出"wrong number of points"。
不论哪个选项,如果格式、点数量都符合要求,但构成任一条线的两个点坐标重合,输出"points coincide",
源码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double x1,y1;
double x2,y2;
double x3,y3;
double x4,y4;
double x,y;
String s = input.nextLine();
String s1,s2;
String[] a = new String[10];
String[] b = new String[2];
if(!s.matches("^[0-9]:((\\-|\\+)?\\d+(\\.\\d+)?,(\\-|\\+)?\\d+(\\.\\d+)? ){1,4}(\\-|\\+)?\\d+(\\.\\d+)?,(\\-|\\+)?\\d+(\\.\\d+)?$"))
{
System.out.println("Wrong Format");
return;
}
s1 = s.substring(0, 1);
s2 = s.substring(2);
a = s2.split(" ");
if(s1.equals("1"))
{
if(!numme(a,2))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
if(x1==x2&&y1==y2)
{
System.out.println("points coincide");
return;
}
if(panxielv(x1,y1,x2,y2))
{
System.out.println("Slope does not exist");
return;
}
System.out.println(xielv(x1,y1,x2,y2));
}
else if(s1.equals("2"))
{
if(!numme(a,3))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x3==x2&&y3==y2))
{
System.out.println("points coincide");
return;
}
System.out.println(Math.abs((y1-y2)*x3+(x2-x1)*y3+x1*y2-y1*x2)/Math.sqrt(Math.pow(y1-y2, 2)+Math.pow(x1-x2, 2)));
}
else if(s1.equals("3"))
{
if(!numme(a,3))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x3==x2&&y3==y2))
{
System.out.println("points coincide");
return;
}
if(xielv(x1,y1,x2,y2)==xielv(x2,y2,x3,y3))
System.out.println("true");
else
System.out.println("false");
}
else if(s1.equals("4"))
{
if(!numme(a,4))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
b = a[3].split(",");
x4 = Double.valueOf(b[0]);
y4 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x1==x4&&y1==y4)||(x3==x2&&y3==y2)||(x4==x2&&y4==y2)||(x3==x4&&y3==y4))
{
System.out.println("points coincide");
return;
}
if(panxielv(x1,y1,x2,y2)&&panxielv(x4,y4,x3,y3))
System.out.println("true");
else if(panxielv(x1,y1,x2,y2)||panxielv(x4,y4,x3,y3))
System.out.println("false");
else if(xielv(x1,y1,x2,y2)==xielv(x4,y4,x3,y3))
System.out.println("true");
else
System.out.println("false");
}
else if(s1.equals("5"))
{
if(!numme(a,4))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
b = a[3].split(",");
x4 = Double.valueOf(b[0]);
y4 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x3==x4&&y3==y4))
{
System.out.println("points coincide");
return;
}
if(xielv(x1,y1,x2,y2)==xielv(x3,y3,x4,y4))
{
System.out.println("is parallel lines,have no intersection point");
return;
}
y = ((y2-y1)*(x4*y3-x3*y4)-(x2*y1-x1*y2)*(y4-y3))/((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3));
x = (y*(x2-x1)-( x2*y1-x1*y2))/(y2-y1);
if((x==x1&&y1==y)||(x==x2&&y2==y)||(x==x3&&y3==y)||(x==x4&&y4==y))
{
System.out.println(x+","+y+" flase");
}
else
{
System.out.println(x+","+y+" true");
}
}
else
{
System.out.println("Wrong Format");
return;
}
}
static boolean numme(String []s,int n)
{
if(s.length!=n)
return false;
else
return true;
}
static double xielv(double x1,double y1,double x2,double y2)
{
return (y2-y1)/(x2-x1);
}
static boolean panxielv(double x1,double y1,double x2,double y2)
{
if(x1==x2)
return true;
else
return false;
}
}
7-3 点线形系列3-三角形的计算
用户输入一组选项和数据,进行与三角形有关的计算。选项包括:
1:输入三个点坐标,判断是否是等腰三角形、等边三角形,判断结果输出true/false,两个结果之间以一个英文空格符分隔。
2:输入三个点坐标,输出周长、面积、重心坐标,三个参数之间以一个英文空格分隔,坐标之间以英文","分隔。
3:输入三个点坐标,输出是钝角、直角还是锐角三角形,依次输出三个判断结果(true/false),以一个英文空格分隔,
4:输入五个点坐标,输出前两个点所在的直线与三个点所构成的三角形相交的交点数量,如果交点有两个,则按面积大小依次输出三角形被直线分割成两部分的面积。若直线与三角形一条线重合,输出"The point is on the edge of the triangle"
5:输入四个点坐标,输出第一个是否在后三个点所构成的三角形的内部(输出in the triangle/outof triangle)。
必须使用射线法,原理:由第一个点往任一方向做一射线,射线与三角形的边的交点(不含点本身)数量如果为1,则在三角形内部。如果交点有两个或0个,则在三角形之外。若点在三角形的某条边上,输出"on the triangle"
输入格式:
基本格式:选项+":"+坐标x+","+坐标y+" "+坐标x+","+坐标y。点的x、y坐标之间以英文","分隔,点与点之间以一个英文空格分隔。
输出格式:
基本输出格式见每种选项的描述。
异常情况输出:
如果不符合基本格式,输出"Wrong Format"。
如果符合基本格式,但输入点的数量不符合要求,输出"wrong number of points"。
如果输入的三个点无法构成三角形,输出"data error"。
注意:输出的数据若小数点后超过6位,只保留小数点后6位,多余部分采用四舍五入规则进到最低位。小数点后若不足6位,按原始位数显示,不必补齐。例如:1/3的结果按格式输出为 0.333333,1.0按格式输出为1.0
选项4中所输入线的两个点坐标重合,输出"points coincide",
源码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double x1,y1;
double x2,y2;
double x3,y3;
double x4,y4;
double x5,y5;
double x,y;
String s = input.nextLine();
String s1,s2;
String[] a = new String[10];
String[] b = new String[2];
if(!s.matches("^[0-9]:((\\-|\\+)?\\d+(\\.\\d+)?,(\\-|\\+)?\\d+(\\.\\d+)? ){1,4}(\\-|\\+)?\\d+(\\.\\d+)?,(\\-|\\+)?\\d+(\\.\\d+)?$"))
{
System.out.println("Wrong Format");
return;
}
s1 = s.substring(0, 1);
s2 = s.substring(2);
a = s2.split(" ");
if(s1.equals("1"))
{
if(!numme(a,3))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x3==x2&&y3==y2))
{
System.out.println("points coincide");
return;
}
if(!sanpan(x1,y1,x2,y2,x3,y3))
{
System.out.println("data error");
return;
}
double l1 = juli(x1,y1,x2,y2);
double l2 = juli(x3,y3,x2,y2);
double l3 = juli(x1,y1,x3,y3);
if(l1==l2&&l2==l3)
System.out.print("true ");
else
System.out.print("false ");
if(l1==l2||l2==l3||l1==l3)
System.out.println("true");
else
System.out.println("false");
}
else if(s1.equals("2"))
{
if(!numme(a,3))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x3==x2&&y3==y2))
{
System.out.println("points coincide");
return;
}
if(!sanpan(x1,y1,x2,y2,x3,y3))
{
System.out.println("data error");
return;
}
double l1 = juli(x1,y1,x2,y2);
double l2 = juli(x3,y3,x2,y2);
double l3 = juli(x1,y1,x3,y3);
double l = l1+l2+l3;
double sj = (x1*y2-x1*y3+x2*y3-x2*y1+x3*y1-x2*y2);
x = (x1+x2+x3)/3;
y = (y1+y2+y3)/3;
System.out.println(l+" "+sj+" "+x+","+y);
}
else if(s1.equals("3"))
{
if(!numme(a,3))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x3==x2&&y3==y2))
{
System.out.println("points coincide");
return;
}
if(!sanpan(x1,y1,x2,y2,x3,y3))
{
System.out.println("data error");
return;
}
double l1 = juli(x1,y1,x2,y2);
double l2 = juli(x3,y3,x2,y2);
double l3 = juli(x1,y1,x3,y3);
double at = (Math.pow(l1, 2)+Math.pow(l3, 2)-Math.pow(l2, 2))/2*l1*l3;
double bt = (Math.pow(l1, 2)+Math.pow(l2, 2)-Math.pow(l3, 2))/2*l1*l2;
double ct = (Math.pow(l2, 2)+Math.pow(l3, 2)-Math.pow(l1, 2))/2*l2*l3;
if(at<0||bt<0||ct<0)
System.out.print("true ");
else
System.out.print("false ");
if(at==0||bt==0||ct==0)
System.out.print("true ");
else
System.out.print("false ");
if(at>0&&bt>0&&ct>0)
System.out.print("true");
else
System.out.print("false");
}
else if(s1.equals("4"))
{
if(!numme(a,5))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
b = a[3].split(",");
x4 = Double.valueOf(b[0]);
y4 = Double.valueOf(b[1]);
b = a[4].split(",");
x5 = Double.valueOf(b[0]);
y5 = Double.valueOf(b[1]);
if(x1==x2&&y1==y2)
{
System.out.println("points coincide");
return;
}
if(!sanpan(x4,y4,x5,y5,x3,y3))
{
System.out.println("data error");
return;
}
double xl1 = xielv(x3,y3,x4,y4);
double xl2 = xielv(x5,y5,x4,y4);
double xl3 = xielv(x3,y3,x5,y5);
double xl = xielv(x1,y1,x2,y2);
int num = 0;
double bx = y1-xl*x1;
double bx1 = y3-xl1*x3;
double bx2 = y5-xl2*x5;
double bx3 = y3-xl3*x3;
if((xl==xl1&&bx==bx1)||(xl==xl2&&bx==bx2)||(xl==xl3&&bx==bx3))
{
System.out.println("The point is on the edge of the triangle");
return;
}
double[] zx = new double[3];
double[] zy = new double[3];
double Ax = -xl;
double Bx = 1;
double Cx = -bx;
int bit1 = 0;
int bit2 = 0;
int bit3 = 0;
double mian1;
double mian2;
if(xl!=xl1)
{
if((Ax*x4+Bx*y4+Cx)*(Ax*x3+Bx*y3+Cx)<0)
{
zx[0] = (bx1-bx)/(xl-xl1);
zy[0] = xl*zx[num]+bx;
num++;
bit1 = 1;
}
}
if(xl!=xl2)
{
if((Ax*x4+Bx*y4+Cx)*(Ax*x5+Bx*y5+Cx)<0)
{
zx[1] = (bx1-bx)/(xl-xl1);
zy[1] = xl*zx[num]+bx;
num++;
bit2 = 1;
}
}
if(xl!=xl3)
{
if((Ax*x3+Bx*y3+Cx)*(Ax*x5+Bx*y5+Cx)<0)
{
zx[2] = (bx1-bx)/(xl-xl1);
zy[2] = xl*zx[num]+bx;
num++;
bit3 = 1;
}
}
System.out.print(num);
if(num==2)
{
if(bit1==1&&bit2==1)
{
mian1 = (zx[0]*zy[1]-zx[0]*y4+zx[1]*y4-zx[1]*zy[0]+x4*zy[0]-zx[1]*zy[1]);
mian2 = (x4*y5-x4*y3+x5*y3-x5*y4+x3*y4-x5*y5)-mian1;
}
else if(bit1==1&&bit3==1)
{
mian1 = (zx[0]*zy[2]-zx[0]*y3+zx[2]*y3-zx[2]*zy[0]+x3*zy[0]-zx[2]*zy[1]);
mian2 = (x4*y5-x4*y3+x5*y3-x5*y4+x3*y4-x5*y5)-mian1;
}
else
{
mian1 = (zx[2]*zy[1]-zx[2]*y5+zx[1]*y5-zx[1]*zy[2]+x5*zy[2]-zx[1]*zy[1]);
mian2 = (x4*y5-x4*y3+x5*y3-x5*y4+x3*y4-x5*y5)-mian1;
}
System.out.print(" "+mian1+" "+mian2);
}
//(x1*y2-x1*y3+x2*y3-x2*y1+x3*y1-x2*y2);
}
else if(s1.equals("5"))
{
if(!numme(a,4))
{
System.out.println("wrong number of points");
return;
}
b = a[0].split(",");
x1 = Double.valueOf(b[0]);
y1 = Double.valueOf(b[1]);
b = a[1].split(",");
x2 = Double.valueOf(b[0]);
y2 = Double.valueOf(b[1]);
b = a[2].split(",");
x3 = Double.valueOf(b[0]);
y3 = Double.valueOf(b[1]);
b = a[3].split(",");
x4 = Double.valueOf(b[0]);
y4 = Double.valueOf(b[1]);
if((x1==x2&&y1==y2)||(x1==x3&&y1==y3)||(x1==x4&&y1==y4)||(x3==x2&&y3==y2)||(x4==x2&&y4==y2)||(x3==x4&&y3==y4))
{
System.out.println("points coincide");
return;
}
if(xielv(x1,y1,x2,y2)==xielv(x3,y3,x4,y4))
{
System.out.println("is parallel lines,have no intersection point");
return;
}
y = ((y2-y1)*(x4*y3-x3*y4)-(x2*y1-x1*y2)*(y4-y3))/((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3));
x = (y*(x2-x1)-( x2*y1-x1*y2))/(y2-y1);
if((x==x1&&y1==y)||(x==x2&&y2==y)||(x==x3&&y3==y)||(x==x4&&y4==y))
{
System.out.println(x+","+y+" flase");
}
else
{
System.out.println(x+","+y+" true");
}
}
else
{
System.out.println("Wrong Format");
return;
}
}
static boolean numme(String []s,int n)
{
if(s.length!=n)
return false;
else
return true;
}
static double xielv(double x1,double y1,double x2,double y2)
{
return (y2-y1)/(x2-x1);
}
static boolean sanpan(double x1,double y1,double x2,double y2,double x3,double y3)
{
if(panxielv(x1,y1,x2,y2)&&panxielv(x3,y3,x2,y2)||panxielv(x1,y1,x2,y2)&&panxielv(x3,y3,x1,y1)||panxielv(x1,y1,x3,y3)&&panxielv(x3,y3,x2,y2))
return false;
else if(panxielv(x1,y1,x2,y2)&&xielv(x1,y1,x3,y3)==xielv(x3,y3,x2,y2))
return false;
else if(panxielv(x3,y3,x2,y2)&&xielv(x1,y1,x2,y2)==xielv(x3,y3,x1,y1))
return false;
else if(panxielv(x3,y3,x1,y1)&&xielv(x1,y1,x2,y2)==xielv(x3,y3,x2,y2))
return false;
if(xielv(x1,y1,x2,y2)==xielv(x3,y3,x2,y2)||xielv(x1,y1,x2,y2)==xielv(x3,y3,x1,y1)||xielv(x1,y1,x3,y3)==xielv(x3,y3,x2,y2))
return false;
else
return true;
}
static double juli(double x1,double y1,double x2,double y2)
{
return Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
}
static boolean panxielv(double x1,double y1,double x2,double y2)
{
if(x1==x2)
return true;
else
return false;
}
}
三、采坑心得
一定要少用if语句,不然各种情况一个接着一个,代码质量就会变得非常差。
四、改进建议
所有的输入样例可以再多一些,有的情况确实是短时间内想不到的。
五、总结
做完这三次作业,对于java的熟悉程度明显提高。有些在课堂没有听懂的,通过不断查找资料也能自己解决了,比如正则表达式。但是我自己对于类这个概念掌握的还不是很好,我还不是很明确到底怎样去建好一个类。我觉得在课后时间我应该花更多时间去了解这个概念。还有少用IF语句。
标签:总结,y2,题目,y1,x2,x3,y3,x1 From: https://www.cnblogs.com/dyc0201/p/16748795.html