闲的无聊写个脚本画统计图
lua吧
全部回复
仅看楼主
level 1
索特127✆ 楼主
如题
2020年04月08日 00点04分 1
level 1
索特127✆ 楼主
-- Copyright(C) 2020 Suote127
-- Draw a total table by some character
function get_max(array)
local max=array[0]
for index,value in ipairs(array)
do
if(max<value)
then
max=value
end
end
return max
end
print("Enter the height of the graphic:")
height=io.read()
dataList={}
print("Enter your data one by one,make sure there is only one on each lines and end with 'end'")
data=io.read()
count=0
while(data~="end")
do
dataList[count]=tonumber(data)
count=count+1
data=io.read()
end
max=get_max(dataList)
step=max/height
side=max
print("A character is "..step)
for i=1,max/step
do
line="| "
if(dataList[0]>=side)
then
line=line.."- "
else
line=line.." "
end
for index,value in ipairs(dataList)
do
if(value>=side)
then
line=line.."- "
else
line=line.." "
end
end
side=side-step
print(line)
end
2020年04月08日 00点04分 2
空格给吃了....
2020年04月08日 00点04分
level 1
索特127✆ 楼主
2020年04月08日 00点04分 3
1