当前位置: 首页 > 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.yayakq.cn/news/536947/

相关文章:

  • 用php做网站不用框架惠州专门做网站
  • 专业网站设计网站网站开发为什么采取ssh框架
  • 电子商务网站建设规划说明书盐城网站建设与网页制作
  • nike网站建设方案做纺织的用什么网站
  • 建设商城网站费用婚礼效果图网站
  • 企业网站源码 asp版式设计模板网站
  • 网站开发吗和APP软件一样吗wordpress建立店铺
  • 龙岩网站建设方案书做网站用不用云服务器
  • 在线编辑ppt的网站重庆市工程建设信息网证书查询
  • 手机定制网站贵州网站推广优化
  • c 2015 做网站网站新建设请示
  • 做土特产的网站苏州设计网页网站好
  • 广告案例网站推广普通话手抄报简单又好看内容
  • 做网站简单需要什么软件昆明网络公司开发
  • 怎么样进行网站建设怎么做公众号小程序
  • 中国工程建设管理协会网站html5 门户网站模版
  • 关于文明网站建设存在的问题用群晖建wordpress
  • 云南百度智能建站网站开发如何修改字体
  • 付费做网站关键词优化是怎么做的呀html5网站报价明细
  • 高端网站定制的方法企业it外包服务公司
  • 做相册的网站(网易关键字优化工具
  • 苏州网站建设费用好123设为主页官网网址大全
  • 服装网站建设项目实施报告范文网站建设的切片是什么
  • 网站建设的流程电子商务一般网站是用什么框架做的
  • 专业的建设网站服务公司wordpress好用的文件管理
  • 网站建设网上书店求有题目做的学习网站
  • 做网站带吗北京包装设计公司
  • 移动端高端网站目前h5页面的制作工具有哪些
  • 河北廊坊百度建站瓯海建设网站
  • 公司网站建设佛山哪家好wordpress教程安装教程