Android筆試總結(4)

發表于:2013-06-03來源:Csdn作者:xyz_lmn點擊數: 標簽:Android
this.count = count; } public Node getNextNode() { return nextNode; } publicvoid setNextNode(Node nextNode) { this.nextNode = nextNode; } } ReverseSingleLink.java publicclass ReverseSingleLink { public

  this.count = count;

  }

  public Node getNextNode() {

  return nextNode;

  }

  publicvoid setNextNode(Node nextNode) {

  this.nextNode = nextNode;

  }

  }

  ReverseSingleLink.java

  publicclass ReverseSingleLink {

  publicstatic Node revSingleLink(Node head){

  if(head ==null){ //鏈表為空不能逆序

  return head;

  }

  if(head.getNextNode()==null){ //如果只有一個結點,當然逆過來也是同一個

  return head;

  }

  Node rhead = revSingleLink(head.getNextNode());

  head.getNextNode().setNextNode(head);

  head.setNextNode(null);

  return rhead;

  }

  publicstaticvoid main(String[] args){

  Node head =new Node(0);

  Node temp1 =null,temp2 =null;

  for(int i=1;i<100;i++){

  temp1 =new Node(i);

  if(i==1){

  head.setNextNode(temp1);

  }else{

  temp2.setNextNode(temp1);

  }

  temp2 = temp1;

  }

  head = revSingleLink(head);

  while(head!=null){

  head = head.getNextNode();

  }

  }

  }

原文轉自:http://blog.csdn.net/xyz_lmn/article/details/6922224

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97