熟悉一下Java。。。

package ChianTable;

import java.util.Scanner;

/**
* Created by Administrator on 2018/3/26.
*/
public class LinkedList { private LinkedList prev;
private LinkedList next;
private int val; private LinkedList head;
private LinkedList rear; public LinkedList() {
super();
} public LinkedList(LinkedList p, LinkedList n, int v) {
super();
this.prev = p;
this.next = n;
this.val = v;
} public LinkedList Create() { Scanner type = new Scanner(System.in);
int val = type.nextInt(); LinkedList nextNode = new LinkedList(null, null, val);
this.head = nextNode;
while ((val = type.nextInt()) != 0) {
LinkedList curr = new LinkedList(nextNode, null, val);
nextNode.next = curr;
nextNode = curr;
}
this.rear = nextNode;
nextNode.next = null; return this.head;
} public void nextprint() {
if (this.head != null) {
System.out.println(this.head.val);
this.head = this.head.next;
nextprint();
}
} public void prevprint() {
if (this.rear != null) {
System.out.println(this.rear.val);
this.rear = this.rear.prev;
prevprint();
}
} }

  测试:

package main;

import ChianTable.LinkedList;

public class Main {

    public static void main(String [] args) {

        LinkedList linkedlist = new LinkedList();

        linkedlist.Create();
linkedlist.nextprint();
linkedlist.prevprint(); }
}

  

最新文章

  1. zookeeper集群某个follower启动失败
  2. zoj 3888 线段树 ***
  3. Objective-C和其他C指针的转换
  4. python构建模拟模型——网站独立访问用户数量
  5. python_day10_IO多路复用
  6. 折腾了一早上的C# WPF ListView+Grid 实现图片+文字 自动换行排列 类似Windows资源管理器效果
  7. PAIP.提升效率----论项目知识库的建设。。
  8. Cmake调用NSIS(一个可执行文件,其实就是一个编译器)编译NSIS脚本问题研究
  9. git config and options core.bare hard
  10. (C#)利用Aspose.Cells组件导入导出excel文件
  11. [51nod1671]货物运输
  12. selenium+chrome抓取淘宝搜索抓娃娃关键页面
  13. 五子棋的判断输赢规则 -- java编程(简单优化完整版)
  14. 计蒜客NOIP模拟赛(2) D2T2紫色百合
  15. C#线程同步(2)- 临界区&Monitor
  16. [Android] Android RecycleView和ListView 自定义Adapter封装类
  17. Scala编程基础
  18. PHP中一些常用知识点
  19. ORACLE procedure 一个参数分解成多个字符一点建议
  20. 22-Python3 输入和输出

热门文章

  1. PowerDesigner 16.5安装、激活
  2. ubuntu 安装 gd
  3. Mac安装php扩展redis遇到的问题,执行phpize问题
  4. 【PAT甲级】1083 List Grades (25 分)
  5. 【C语言】输入5个整数并按输入顺序逆序输出
  6. phpstorm问题
  7. C:sizeof 运算符
  8. ROM, RAM, NVRAM and Flash Memory on Cisco Routers
  9. 安装Ubuntu后的一些配置
  10. Java IO流详解(一)——简单介绍