1 Star 0 Fork 0

besti1923/JAVA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
linkedlisttexample1923.java 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
yifei 提交于 5年前 . shiyan6
package text.java;
public class linkedlisttexample1923 {
public static void main(String[] args) {
student1 hao =new student1("hao",2,"打游戏");
student1 guo =new student1("guo",25,"下棋");
student1 best =new student1("best",16,"学");
student1 yang =new student1("yang",26,"泡");
student1 niu =new student1("niu",28,"java");
student1 head =hao;
hao.next =guo;
guo.next=best;
best.next=yang;
sort(head,4);
//头插法
/*niu.next=head;
head=niu;*/
//尾插法
/*student1 point =head;
while(point.next != null){
point=point.next;
System.out.println(point.name);
}
point.next=niu;
printlinkedlist(head);*/
//删除头 新head
//删除尾
}
public static void printlinkedlist(student1 head) {
student1 point =head;
while(point != null){
System.out.println(point.name);
point=point.next;
}
}
public static void sort(student1 head,int size){
student1 point =head;
student1 temp;
student1 temp2;
int i;
int a,b;
for(i=0;i<size;i=i+1) {
point = head;
while(point.next.next!=null){
a=point.next.number;
b=point.next.next.number;
if(a>b){
System.out.println("A");
temp=point.next;
temp2=point.next.next;
point.next=temp2;
temp2.next=temp;
temp.next=point.next.next.next;
}
point=point.next;
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/besti1923/java.git
git@gitee.com:besti1923/java.git
besti1923
java
JAVA
master

搜索帮助