简单轮询算法实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
fun main(args: Array<String>) {
val list = arrayListOf(0, 1, 2)

var prevIndex = -1
for (value in (1..7)) { // 执行7次测试
val currentIndex = (prevIndex + 1) % list.size

print("${list[currentIndex]} \t")

prevIndex = currentIndex
}
}

// 0 1 2 0 1 2 0
// TODO 加权
# Java

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×