package test1;
import java.util.*;
public class BinarySortTree {
public class node{
int value;
node next;
public node(int value){
this.value=value;
}
public void add(node node1){
this.next=node1;
}
public void show(node node1){
if(node1==null)return;
else {
show(node1.next);
System.out.print(node1.value+" ");
}
}
}
public static void main(String [] args){
BinarySortTree n=new BinarySortTree();
Scanner sc=new Scanner(System.in);
for(int i=0;i<5;i++){
int a=sc.nextInt();
n.add(n.new node(a));
}
}
}
package intersectionarrays;
import java.util.*;
import intersectionarrays.OuterClass.InnerClass;
public class BinarySortTree {
public class node {
int value;
node next;
public node(int value) {
this.value = value;
}
public void add(node node1) {
this.next = node1;
}
public void show(node node1) {
if (node1 == null)
return;
else {
show(node1.next);
System.out.print(node1.value + " ");
}
}
}
public static void main(String[] args) {
BinarySortTree n = new BinarySortTree();
BinarySortTree.node bn = n.new node(0);
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 5; i++) {
int a = sc.nextInt();
bn.add(n.new node(a));
}
}
}
import java.util.*;
class node {
int value;
node next;
public node(int value) {
this.value = value;
}
public void add(node node1) {
this.next = node1;
}
public void show(node node1) {
if (node1 == null)
return;
else {
show(node1.next);
System.out.print(node1.value + " ");
}
}
}
public class BinarySortTree2 {
public static void main(String[] args) {
node n = new node(0);
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 5; i++) {
int a = sc.nextInt();
n.add(new node(a));
}
}
}
不使用内部类更简单