poster
2019-12-10, 20:48
我正在尝试解决Code Golf:Build Me a Arc (https://stackoverflow.com/questions/3365487/code-golf-build-me-an-arc/3369332#3369332)问题。我的解决方案还不错,但是我认为,有一种更简单的方法可以做到这一点。给定n ,有人知道如何生成这样的nxn矩阵吗?我花了57个字符!
3 0 0 0 2 0 0 0 1 0 3 0 0 2 0 0 1 0 0 0 3 0 2 0 1 0 0 0 0 0 3 2 1 0 0 0 4 4 4 4 8 8 8 8 8 0 0 0 5 6 7 0 0 0 0 0 5 0 6 0 7 0 0 0 5 0 0 6 0 0 7 0 5 0 0 0 6 0 0 0 7 我想将其中的一些矩阵 (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f16-5872.html#f16-6070)弄巧成拙。
更新:
这就是我现在得到的方式。
%%# Create the grid [XY]=meshgrid(-r:r); %%# Compute the angles in degrees T=atan2(-Y,X)/pi*180; %%# Get all the angles T=T+(T
3 0 0 0 2 0 0 0 1 0 3 0 0 2 0 0 1 0 0 0 3 0 2 0 1 0 0 0 0 0 3 2 1 0 0 0 4 4 4 4 8 8 8 8 8 0 0 0 5 6 7 0 0 0 0 0 5 0 6 0 7 0 0 0 5 0 0 6 0 0 7 0 5 0 0 0 6 0 0 0 7 我想将其中的一些矩阵 (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f16-5872.html#f16-6070)弄巧成拙。
更新:
这就是我现在得到的方式。
%%# Create the grid [XY]=meshgrid(-r:r); %%# Compute the angles in degrees T=atan2(-Y,X)/pi*180; %%# Get all the angles T=T+(T