Size: a a a

2020 October 16

PR

Prathmesh Raut in pro.lua
fgntfg
Add all elements to the table, than iterate over the table and find max value.
How plz
источник

f

fgntfg in pro.lua
Do you need full code or idea how to write the code?
источник

f

fgntfg in pro.lua
Do you wanna learn lua or not?
источник

PR

Prathmesh Raut in pro.lua
Yes little bit...i am starting but confused on this probelm
источник

f

fgntfg in pro.lua
Prathmesh Raut
Yes little bit...i am starting but confused on this probelm
show me what code you wrote already
источник

PR

Prathmesh Raut in pro.lua
Only logic know but how to done in that confused
источник

PR

Prathmesh Raut in pro.lua
ok, that's the logic
iterate over every line
if the score is higher than the maximum local score known, change the maximum local score and the name of the student
once done, the maximum local score will be the highest score (global maximum score)
источник

PR

Prathmesh Raut in pro.lua
But how write code in that i confused
источник

PR

Prathmesh Raut in pro.lua
Can you plz help me
источник

f

fgntfg in pro.lua
Prathmesh Raut
ok, that's the logic
iterate over every line
if the score is higher than the maximum local score known, change the maximum local score and the name of the student
once done, the maximum local score will be the highest score (global maximum score)
you coppied this from somewhere
источник

PR

Prathmesh Raut in pro.lua
Yes my frd send me
источник

f

fgntfg in pro.lua
I can, but I wouldn't help lazy boy
источник

f

fgntfg in pro.lua
You want solution, but not knowledge, I disrespect this
источник

PR

Prathmesh Raut in pro.lua
I am not lazy i am try to solved in last 3 hrs
источник

PR

Prathmesh Raut in pro.lua
But get confused
источник

f

fgntfg in pro.lua
Show me your code than, and we will figure out what wrong with the code
источник

PR

Prathmesh Raut in pro.lua
Okay
источник

S

Snusmumriken in pro.lua
Prathmesh Raut
Input:
1
5
Sam 40.08
Riya 30.7
Harry 41
Anne 35.2
Peter 36.6

Output:
Harry

Explanation:
The maximum score of student is 41 which belong to "Harry"
Solution using FFI : )
local ffi = require'ffi'

ffi.cdef[[
typedef struct Student {
 const char * name;
 float score;
} Student;]]

local case, count

while not case do
 print("Write testcase count (number):")
 case = tonumber(io.read("*l"))
end

while not count do
 print("Write students count (number):")
 count = tonumber(io.read("*l"))
end


local students = ffi.new("Student[?]", count)

for i = 0, count - 1 do
 local studentname, score
 while not studentname do
   print("Write " .. i + 1 .. " student (name score):")
   local line = io.read("*l")
   studentname, score = line:match("(%w+).-(%-?%d+%.?%d*)")
   if studentname then
     print("Student #" .. i .. ": ", studentname, "score: ", score)
     students[i].name = studentname
     students[i].score = tonumber(score)
   end
 end
end

local maxstudent = students[0]
for i = 1, count - 1 do
 if students[i].score > maxstudent.score then
   maxstudent = students[i]
 end
end

print("Coolest student is ", ffi.string(maxstudent.name), ", he's score is:", maxstudent.score)
источник

PR

Prathmesh Raut in pro.lua
Thx you very much
источник

PR

Prathmesh Raut in pro.lua
Using lua
источник