代码拉取完成,页面将自动刷新
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;
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。