量化算法题

package com.zb.swdata.core;

public class Test {
public static class Node{
public Node nextnode;
private Integer num;

public Node get(){
return nextnode;
}

public Integer getNum() {
return num;
}

public void setNum(Integer num) {
this.num = num;
}

public void run(){
Node[] nodelist = new Node[100];
Node nodetmp = null;
for(int i= 0; i < nodelist.length; i++ ){
nodelist[i] = new Node();
nodelist[i].num = i + 1;
if (i == 0) {
nodetmp = nodelist[i];
continue;
}
else {
nodetmp.nextnode = nodelist[i];
nodetmp = nodelist[i];
}
}
nodelist[99].nextnode = nodelist[0];

Node cur = nodelist[0];
while (cur != cur.nextnode){
Node tmp1 = cur.nextnode.nextnode;
cur.nextnode = cur.nextnode.nextnode;
cur = tmp1;
System.out.println(cur.num);
}

System.out.println(cur.num);
}
}


public static void main(String[] args){
Node node = new Node();
node.run();
}
}
posted @ 2022-10-28 17:12  谭志宇  阅读(22)  评论(0编辑  收藏  举报