Excel VBA中,168 160 147 138字节(100×在尺度单元像素)
多亏了KyleKanos,节省了8个
字节多亏了Taylor Scott,节省了22个字节
Sub g(n)
For i=0To 1
For x=-3To 3Step.01
y=n^x*Cos([Pi()]*x)
m=IIf(y<m,y,m)
If i Then Cells(500*(1-y/m)+1,(x+3)*100+1)="#
Next x,i
End Sub
格式化后,它看起来像这样:
Sub g(n)
For i = 0 To 1
For x = -3 To 3 Step 0.01
y = n ^ x * Cos([Pi()] * x)
m = IIf(y < m, y, m)
If i Then Cells(500 * (1 - y / m) + 1, (x + 3) * 100 + 1) = "#"
Next x, i
End Sub
有趣的事实:VBA不具有一个内置的pi
变量,所以我们必须把它作为评价工作表函数它确实存在。
n = 1 n = 2
我从193字节的图表版本开始,但是确实得到了更好的结果。
Sub c(n)
For x=-3To 3Step 0.05
r=r+1
Cells(r,1)=n^x*Cos(Atn(1)*4*x)
Next
With ActiveSheet.Shapes.AddChart(xlLine).Chart
.SetSourceData Range("A1:A121")
.Axes(xlCategory).Delete
End With
End Sub
n = 1 n = 2
ASCII art is disallowed.
(ಥ﹏ಥ)