Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Conta valores acima da média - LUA
local sum, result = 0, 0 local intlist = {} listlen = io.read("*n"); if (listlen > 0 and listlen < 100) then -- Read input into an array and compute the sum for counter = 1, listlen, 1 do intlist[counter] = io.read("*n"); sum = sum + intlist[counter]; end -- Compute the average average = sum / listlen; -- Count the input values that are > average for num, value in ipairs(intlist) do if (num > average) then result = result + 1 end end -- Print result print ("Number of values > average is: ", result, "\n"); else print ("Error--input list length is not legal \n"); end
run
|
edit
|
history
|
help
0
test123
BasicTablePrinterV2
roulette
Find primes until e
l
Testingassets
Lua Angle Cheatsheet
as
1
Lua recursion with function