当前位置: 首页> 财经> 股票 > 哪个地区网站建设好_设计派官网_免费信息推广平台_2021百度最新收录方法

哪个地区网站建设好_设计派官网_免费信息推广平台_2021百度最新收录方法

时间:2025/8/6 18:36:13来源:https://blog.csdn.net/weixin_63261270/article/details/146136884 浏览次数:0次
哪个地区网站建设好_设计派官网_免费信息推广平台_2021百度最新收录方法

package LinkByHand;public class LinkList {public Node head =null;//尾插法public void insert(int value) {Node node = new Node(value);if(head ==null) {head =node;return;}Node index = head;while(index.next!=null) {index =index.next;}index.next = node;}//头插法public void insertHead(int value) {Node node = new Node(value);if(head ==null) {head =node;return;}node.next =head;head=node;}//获取链表的长度public int getLen() {int count = 0;Node index = head;while(index!=null) {count++;index =index.next;}return count;}//链表中查数据public int search(int value) {int position =-1;Node index = head;while(index!=null) {position++;if(index.value==value) {return position;}index =index.next;}return -1;}	//指定位置插入public void insertAtPosition(int value,int position) {if(position<0||position>getLen()) {System.out.println("插入位置不合理");return;}if(position==0) {insertHead(value);}else  if(position==getLen()){insert(value);}else {Node node =new Node(value);Node index =head;Node pre = null;int current =0;while(index!=null) {if(current==position) {node.next = index;pre.next =node;return;}pre = index;index =index.next;current++;}}}//删除指定位置的节点public void deleteAtPosition(int position) {if(position<0||position>=getLen()) {System.out.println("删除位置不合理");return;}if(position==0) {head =head.next;}else {Node index = head;Node pre =null;int current =0;while(index!=null) {if(current==position) {//deletepre.next=index.next;return;}pre =index;index =index.next;current++;}}}//输出链表中的值	@Overridepublic String toString() {String res="[ ";Node index =head;while(index!=null) {res+=index.value+" ";index =index.next;}res+="]";return res;}
}

关键字:哪个地区网站建设好_设计派官网_免费信息推广平台_2021百度最新收录方法

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: