## 单链表反序 原

l
lzg14

``````/**
*
* @author Jason Li 2014-5
*
*  面试题： 要求将a-z的26个字母加入一个单链表，输出，然后反序后再输出
*
*/

public static void main(String[] args) {

for (int i = 0; i < 26; i++) {
}
sll.show();
sll.reverse();
sll.show();
}

}

//简单的单链表

private Node tail;// 尾指针

Node tem = new Node();
tem.content = 0;
tem.next = null;
}

//在链表尾部添加
Node tem = new Node();
tem.content = o;
tem.next = null;
tail.next = tem;
tail = tem;
}

// 反序
public void reverse() {
Node cur = insert_point.next; //待插入的节点
Node tmp;

while (cur != null) {
tmp = cur.next; //下一个待插入节点
cur.next = insert_point;//把cur节点插入到插入点之前，
insert_point = cur; //然后当前节点下变为插入点
cur = tmp;
}
tail.next = null;

}

// 显示
public void show() {
while (cur != null) {
System.out.print(cur.content);
cur = cur.next;
if (cur != null)
System.out.print("->");
}
System.out.println();
}

// 节点类
private class Node {
public Object content;
public Node next;
}

}``````

l

### lzg14

2017/06/17
0
0

2016/04/01
242
0
leetcode 2 Add Two Numbers 方法2

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers ......

2015/01/30
0
2

2017/11/11
0
0
2015年1月9日XX大学XX学院考试题

2015/01/09
0
0

stars永恒
27分钟前
0
0

NotFound403

2
0
day22:

1、写一个getinterface.sh 脚本可以接受选项[i，I]，完成下面任务： 1）使用格式：getinterface.sh [-i interface | -I ip] 2）当用户使用-i选项时，显示指定网卡的IP地址；当用户使用-I选项...

2
0
Spring Cloud Alibaba基础教程：使用Nacos实现服务注册与发现

4
0