当前位置: 首页 > news >正文

网站首页百度收录怎么做百度热词指数

网站首页百度收录怎么做,百度热词指数,做网站的害处,兰州高端网站建设在使用以下方法时需要定义一个LinkNode类来定义变量,new一个新对象进行调用,输出时需要定义输出方法 public class ListNode {int value;ListNode next;//public ListNode(int value) {this.value value;}public String toString(){return "ListN…

        在使用以下方法时需要定义一个LinkNode类来定义变量,new一个新对象进行调用,输出时需要定义输出方法

public class ListNode {int value;ListNode next;//public ListNode(int value) {this.value = value;}public String toString(){return "ListNode [value=" + value+", next="+next+"]";}public String toString1(){return "ListNode [value=" + value+"]";}
}

 定义下面方法时需要提前定义头指针

public ListNode head = null;//定义头指针

1.插入,尾插法

//插入,尾插法public void insert(int value){ListNode node = new ListNode(value);if(head==null){head=node;return;}ListNode index = head;while (index.next!=null){index = index.next;}index.next=node;}

2.插入,头插法

//插入,头插法public void headinsert(int value){ListNode node = new ListNode(value);if(head==null){head=node;return;}node.next=head;head=node;}

3.输出链表上的值 

//输出链表上的值public void printLink1(){ListNode index = head;while (index.next!=null){//最后一个value不进入循环System.out.print(index.value+" ");index = index.next;}System.out.println(index.value);}//输出链表上的值public void printLink2(){ListNode index = head;while (index!=null) {//最后一个value进入循环System.out.print(index.value+" ");index = index.next;}}

4.输出链表长度

//输出链表长度public int getListLength(){int temp=0;ListNode index = head;while (index!=null){temp++;index =index.next;}return temp;}

5.查找某个元素是否在链表上

//查找某个元素是否在链表上public boolean contains(int a){boolean b= false;ListNode index =head;if (head==null){b = false;}while (index!=null){if (index.value == a){b= true;}else {b=false;}index =index.next;}return b;}

6.任意位置插入

 //任意位置插入public void addNodeAtIndex(int value,int position){//判断插入位置是否合法if(position<0||position>getListLength()){System.out.println("插入位置不合法");return;}if (position==0){headinsert(value);}else if (position==getListLength()){insert(value);}else {//创建新节点ListNode node = new ListNode(value);ListNode index = head;ListNode pre = null;//找相关位置int count=0;while (index!=null){if (count==position){node.next=index;pre.next=node;return;}pre=index;index=index.next;count++;}}}

7.任意位置删除 

//任意位置删除public void deleteNodeAtIndex(int position){//判断插入位置是否合法if(position<0||position>getListLength()-1){System.out.println("删除位置不合法");return;}//删除位置是0号位置if (position==0){head=head.next;return;}//删除位置不是0号位置ListNode index = head;ListNode pre = null;//找相关位置int count=0;while (index!=null){if (count==position){pre.next=index.next;return;}pre=index;index=index.next;count++;}}

 8.找中间节点,只遍历一次

//找到中间节点,只遍历一遍public ListNode findMiddle(){ListNode fast = head;ListNode show = head;while (fast!=null&&fast.next!=null){fast=fast.next.next;show=show.next;}return show;}

9.判断链表是否成环

 //判断链表是否成环public boolean hasCycle(){ListNode fast = head;ListNode show = head;while (fast!=null&&fast.next!=null){fast=fast.next.next;show=show.next;if (fast==show){return true;}}return false;}

10.判断成环链表的起始节点 

 //判断成环链表的起始节点public ListNode findHasCycle(){ListNode fast = head;ListNode show = head;while (fast!=null&&fast.next!=null){fast=fast.next.next;show=show.next;if (fast==show){show=head;while (show!=fast){fast= fast.next;show= show.next;}return show;}}return null;}

11.截取单链表后k个节点

 //截取单链表后k个节点public ListNode endNode(int k){ListNode fast = head;ListNode show = head;//fast先走k步for (int i = 0; i < k; i++) {fast=fast.next;}while (fast!=null){show= show.next;fast= fast.next;}return show;}

12.翻转链表,在链表上直接翻转 

//翻转链表,在链表上直接翻转public ListNode fanzhuan(){ListNode index = null;ListNode pre = null;while (head!=null){index=head.next;head.next=pre;pre=head;head=index;}head=pre;return head;}

 

 

 

 

 

 

http://www.mmbaike.com/news/69350.html

相关文章:

  • 长春做网站公司长春网站排名上海网站建设方案
  • 深圳龙岗最新疫情内蒙古seo
  • 没有备案的网站可以做淘宝客网站维护合同
  • 淄博外贸网站制作青岛seo推广
  • 免费网站建设 优帮云品牌推广专员
  • 个人网站备案怎么做百度业务推广
  • 郑州网站建设专家怎么让百度收录网站
  • 大埔做网站百度公司简介介绍
  • 医院网站建设策划河南搜索引擎优化
  • dw网站制作中山网站建设公司
  • 网站中怎么做图片的变换南京seo排名优化公司
  • 台湾设计师网站免费域名注册服务网站
  • 蔚县做网站关键词推广seo
  • 谷城今日疫情百度快速收录seo工具软件
  • 河南网站备案地址软文写作什么意思
  • 做区块链网站的公司新闻头条今日要闻国内新闻最新
  • mysql做网站怎么查看数据营销策略从哪几个方面分析
  • 网站做政务网站策划是做什么的
  • 网站建设进展报告百度搜索排行榜风云榜
  • 杭州哪家公司做网站好没经验怎么开广告公司
  • 国内公关公司排名襄阳seo推广
  • 新品牌营销策划方案电商网站seo怎么做
  • 网站开发转码手机搜狗快速收录方法
  • 0元购怎么在网站做seo网站分析工具
  • icp备案网站建设方案书企业网站推广的一般策略
  • 网站页面设计怎么做推广平台软件有哪些
  • css个人简介网站怎么做数据平台
  • 路由器做网站教程网站页面设计模板
  • 成都商城网站制作seo 页面
  • 网络营销网站建设公司百度霸屏推广