Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local i
- local x
- local y
- local amount
- local n 40
- local b = n/2
- local r = 100
- local v = {}
- local m = {}
- -- Stampa del bordo X
- function StampaBordoX()
- i = 0;
- write("+")
- while i < b do
- write("----+")
- i = i + 1
- end
- print()
- end
- -- Equivalente del printf in lua
- function comma_value(amount)
- local formatted, k = amount, 0
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (not k) or k==0 then
- break
- end
- end
- return formatted
- end
- i = 0
- for i=1,b do
- v[i] = math.random(1,r)
- end
- -- Assegnamento della matrice
- x = 0
- StampaBordoX()
- while x < b do
- y = 0
- write("|")
- while y < b do
- m[x][y] = v[math.random(1,n)]
- comma_value(m[x][y])
- y = y + 1
- end
- print()
- StampaBordoX()
- x = x + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement