我有一个带有 PointType 对象的数组:
const coords : array[0..6] of PointType =
((x:220, y:410),
(x:120, y:110),
(x:480, y: 60),
(x:320, y:200),
(x:560, y:190),
(x:390, y:360),
(x:600, y:440));
我需要创建一个循环来遍历所有这些点,但在每次迭代中使用其中的 3 个并返回到开头。像这样:
arrayLength := SizeOf(coords) div SizeOf(PointType);
for i := 1 to (arrayLength-2)
do begin
WriteLn(someFunction(coords[i-1], coords[i], coords[i+1]));
end;
WriteLn(someFunction(coords[arrayLength - 2], coords[arrayLength - 1], coords[0]));
WriteLn(someFunction(coords[arrayLength - 1], coords[0], coords[1]));
是否有一种适当的方法可以在一个操作中完成此操作,而不是指定最后两次迭代?