首页 > 编程语言 >量化算法题

量化算法题

时间:2022-10-28 17:24:56浏览次数:47  
标签:Node nodelist cur nextnode 算法 num 量化 public

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();
}
}

标签:Node,nodelist,cur,nextnode,算法,num,量化,public
From: https://www.cnblogs.com/chengxin1982/p/16836750.html

相关文章