34 lines
970 B
Text
34 lines
970 B
Text
constant fn = open("mlijobs.txt", "r")
|
|
integer maxout = 0, jobnumber
|
|
sequence jobs = {}, maxtime, scanres
|
|
string inout, jobtime
|
|
object line
|
|
while 1 do
|
|
line = gets(fn)
|
|
if atom(line) then exit end if
|
|
scanres = scanf(line,"License %s @ %s for job %d\n")
|
|
if length(scanres)!=1 then
|
|
printf(1,"error scanning line: %s\n",{line})
|
|
{} = wait_key()
|
|
abort(0)
|
|
end if
|
|
{{inout,jobtime,jobnumber}} = scanres
|
|
if inout="OUT" then
|
|
jobs &= jobnumber
|
|
if length(jobs)>maxout then
|
|
maxout = length(jobs)
|
|
maxtime = {jobtime}
|
|
elsif length(jobs)=maxout then
|
|
maxtime = append(maxtime, jobtime)
|
|
end if
|
|
else
|
|
jobs[find(jobnumber,jobs)] = jobs[$]
|
|
jobs = jobs[1..$-1]
|
|
end if
|
|
end while
|
|
close(fn)
|
|
|
|
printf(1, "Maximum simultaneous license use is %d at the following times:\n", maxout)
|
|
for i = 1 to length(maxtime) do
|
|
printf(1, "%s\n", {maxtime[i]})
|
|
end for
|