package com.Cx_330.run;
public class CircleLink {
private static int totalNodes=10;
public static int k=3;
public static void main(String[] args) {
CircleLinkList circleLinkList = new CircleLinkList();
circleLinkList.add(totalNodes);
circleLinkList.showAll();
System.out.println("开始玩抓小鸡了!!!!!!!!!!!!");
circleLinkList.sortByK(k,totalNodes,1);
}
}
class CircleLinkList{
private Node first=null;
public void add(int nums){
Node pro=null;
for (int i = 1; i <= nums; i++) {
Node node=new Node(i);
if(first==null){
first=node;
first.setnext(first);
pro=first;
}else {
while (pro.getnext()!=first){pro=pro.ge
循环单链表之手撕“约瑟夫问题“
最新推荐文章于 2024-08-31 10:44:02 发布