方螺旋坐标 [英] Square Spiral Co-ordinate

查看:102
本文介绍了方螺旋坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定x,y整数是否满足螺旋平方的点(x,y). (0,0)(0,1)(1,1)(1,2)(0,2)(-1,2)(-2,2)(-2,1)(-2,0)ans等等.....

I want to find if a point (x,y)where x,y integers satisfy the spiral square. (0,0) (0,1) (1,1) (1,2) (0,2) (-1,2) (-2,2) (-2,1) (-2,0) ans so on.....

我该怎么做? 我想要Java或C ++函数的逻辑.

How do I do it? I want the logic for a java or c++ function.

推荐答案

执行以下操作:

(operator)(operation)(amount)

其中运算符交替为x,y,x,y,...(为此使用%运算符),运算符交替为+,+,-,-,+,+,-,-,+,+. (再次使用%运算符),金额更改为1,2,3,...

where operator alternates as x,y,x,y,...(use % operator for that), operation alternates as +,+,-,-,+,+,-,-,+,+...(again use % operator for that) and amount changes as 1,2,3,...

这篇关于方螺旋坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆