Lua论分析需求(学好英文)的重要性

时间:2024-04-18 11:34:55

题目是这样的:

Lua论分析需求(学好英文)的重要性


Observe that its base and height are both equal to

, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces.

Write a program that prints a staircase of size .

Function Description

Complete the staircase function in the editor below. It should print a staircase as described above.

例子是这样的:

Lua论分析需求(学好英文)的重要性

What fuck!这是右对齐么???耗尽我的脑细胞,分析每行#号前后需要空格与行数的对应关系。结果只要右对齐就可以了。

 function InitStr(n )
str = {}-- body
for i=,n do
str[i] = {}
for j=,n do
str[i][j] = "#"
end
end
return str
end function staircase1(n)
-- body arr = InitStr(n)
for i=,n do
integer,frac = math.modf((n-i)/)
if(frac > )then
leftSpaceCount = integer +
else
leftSpaceCount = integer
end
for j=,i do
arr[i][leftSpaceCount+j] = "#"
end
print(table.concat(arr[i]))
end
end function staircase(n)
-- body arr = InitStr(n)
for i=,n do
leftSpaceCount = n - i
for j=,leftSpaceCount do
arr[i][j] = " "
end
print(table.concat(arr[i]))
end
end
staircase()