当前位置: 首页 > 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.15wanjia.com/news/185650.html

相关文章:

  • 公众号运营岗位职责seo推广的方法
  • 凡科代理建站登录关于做服饰网站的首页
  • 做网站排名要多少钱wordpress分享到微信朋友圈
  • 合肥建设网站做电影网站能赚钱吗
  • 提供手机自适应网站建设维护厦门网站建设建设公司
  • 自己做cdk兑换码网站哪些网站可以赚钱
  • 做模型网站赚钱么晋州网站建设哪家好
  • 有没有教做化学药品的网站杭州网站建设公司排行
  • 北京网站建设技术托管手机网站建设推荐
  • 新类型 网站怎么建设一个开源平台网站
  • 房地产项目网站建设网站优化建设河南
  • 沈阳专业制作网站专门做进口产品的网站6
  • 新七建设集团有限公司网站如何做一个网页
  • h5类型的网站是怎么做的项目网专栏
  • 延安网站建设网站制作公司深圳
  • 网站外链的建设网站开发与维护是干什么的
  • 国外有哪些设计网站有哪些问题建网站主机
  • 购物网站页面布局深圳网站开发搜行者seo
  • 鞍山手机网站建设网站怎么加留言
  • 代码交易网站公司要搭建网站
  • 哪些经营范围是包含网站开发的海口网吧
  • 德州做网站dzqifan互动营销的案例有哪些
  • 做网站类的网站网站主页没有关键词
  • dw如何用表格做网站永川做网站的
  • 做网站图标的软件wordpress lt
  • 成都手机wap网站制作网络规划设计师一本通
  • 上海 网站公司公司网站做一下多少钱
  • 成都 html5网站中国建盏品牌形象设计大赛公示
  • 怎么制作手机网页网站优化seo教程
  • 电商网站架构酒店网站建设趋势