/inner-spiral-algorithm

This code calculates the coordinates of a given value in the inner spiral algorithm, with the center point at (0,0).

Primary LanguageC++MIT LicenseMIT

inner-spiral-algorithm

This code calculates the coordinates of a given value in the inner spiral algorithm, with the center point at (0,0).

Illustration in table

图片

在这段代码中,我们将向量的坐标系定义为:

Z轴:向上为正半轴,向下为负半轴

X轴:向左为正半轴,向右为负半轴

输出坐标为 ( x , z )

input and output

input range

1 ~ 2147483647

output range

(0,0) ~ (-18536,23170)

Output screenshot

图片