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
xml panel repeater
123
cumulative probability
Hello 2
Uppercase
MXR
test
Code golf - ASCII art #1
ok
Lua recursion with function