狠狠地报错了 不知道是为什么😭
package search;
public class BTS {
public static void main(String[] args) {
// TODO Auto-generated method stub
BTS bts = new BTS();
Node r;
char[][] arr = null;
bts.create(arr);
bts.insertBTS(1002, '王', '男', 2021053, 12345678);
bts.show1(bts);
}
class Node{
int key;
Node lchild;
Node rchild;
Node(){
lchild=rchild=null;
}
}
public Node r; //根节点
public Node f; //存放待删除结点的双亲
public BTS() {
r=null;
}
public void insertBTS(int id,char name,char sex,int classroom,int phone) {
insert(r, id, name, sex, classroom, phone);
}
private Node insert(Node p,int id,char a1,char a12,int classroom,int phone) {
if(p==null) {
p=new Node();
p.key=id;
}
else if(id<p.key)
p.lchild=insert(p.lchild, id, a1, a12, classroom, phone);
else if(id>p.key)
p.rchild=insert(p.rchild, id, a1, a12, classroom, phone);
return p;
}
public void create(char[][] a1) {
r=new Node();
r.key=a1[0][4];
for(int i=0;i<a1.length;i++) {
insert(r, a1[i][0], a1[i][1], a1[i][2], a1[i][3], a1[i][4]);
}
}
public void show1(BTS x) {
show(x.r);
}
public void show(Node p) {
if(p!=null) {
show(p.lchild);
System.out.println(p.key+" ");
show(p.rchild);
}
}
}
package search;
public class BTS {
public static void main(String[] args) {
// TODO Auto-generated method stub
BTS bts = new BTS();
Node r;
char[][] arr = null;
bts.create(arr);
bts.insertBTS(1002, '王', '男', 2021053, 12345678);
bts.show1(bts);
}
class Node{
int key;
Node lchild;
Node rchild;
Node(){
lchild=rchild=null;
}
}
public Node r; //根节点
public Node f; //存放待删除结点的双亲
public BTS() {
r=null;
}
public void insertBTS(int id,char name,char sex,int classroom,int phone) {
insert(r, id, name, sex, classroom, phone);
}
private Node insert(Node p,int id,char a1,char a12,int classroom,int phone) {
if(p==null) {
p=new Node();
p.key=id;
}
else if(id<p.key)
p.lchild=insert(p.lchild, id, a1, a12, classroom, phone);
else if(id>p.key)
p.rchild=insert(p.rchild, id, a1, a12, classroom, phone);
return p;
}
public void create(char[][] a1) {
r=new Node();
r.key=a1[0][4];
for(int i=0;i<a1.length;i++) {
insert(r, a1[i][0], a1[i][1], a1[i][2], a1[i][3], a1[i][4]);
}
}
public void show1(BTS x) {
show(x.r);
}
public void show(Node p) {
if(p!=null) {
show(p.lchild);
System.out.println(p.key+" ");
show(p.rchild);
}
}
}