Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定p(0,0),我如何检索points{(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1)}相对于 p 偏移 1 的周长点。
p(0,0)
points{(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1)}
for(x = p.x -1; x <= p.x + 1; x++) { for(y = p.y -1; y <= p.y + 1; y++) { // Do some stuff with each p } }
通用代码在这里。更改您的编程语言以及存储积分的方式。