Выборы (Тьюринга)
Я учусь Тьюринга прямо сейчас. В настоящее время мы создаем программу для ввода трех оценок, получения двух наивысших оценок, а затем нахождения среднего значения для двух оценок. Я правильно сделал код, но он очень длинный и совсем не эффективен. Мне нужен способ сократить этот код:
%Variables and Contants
var rfirstmark : real
var rsecondmark : real
var rthirdmark : real
var rfirsthigh : real
var rsecondhigh : real
var rthirdhigh : real
var raverage : real
const camount := 2
%Input
put "Enter the first mark."
get rfirstmark
put ""
put "Enter the second mark."
get rsecondmark
put ""
put "Enter the third mark."
get rthirdmark
put ""
%Process
if rfirstmark > rsecondmark then
if rfirstmark > rthirdmark then
rfirsthigh := rfirstmark
end if
end if
if rfirstmark > rthirdmark then
if rfirstmark > rsecondmark then
rfirsthigh := rfirstmark
end if
end if
if rfirstmark < rsecondmark then
if rfirstmark > rthirdmark then
rsecondhigh := rfirstmark
end if
end if
if rfirstmark < rthirdmark then
if rfirstmark > rsecondmark then
rsecondhigh := rfirstmark
end if
end if
if rfirstmark < rsecondmark then
if rfirstmark < rthirdmark then
rthirdhigh := rfirstmark
end if
end if
if rfirstmark < rthirdmark then
if rfirstmark < rsecondmark then
rthirdhigh := rfirstmark
end if
end if
if rsecondmark > rfirstmark then
if rsecondmark > rthirdmark then
rfirsthigh := rsecondmark
end if
end if
if rsecondmark > rthirdmark then
if rsecondmark > rfirstmark then
rfirsthigh := rsecondmark
end if
end if
if rsecondmark < rfirstmark then
if rsecondmark > rthirdmark then
rsecondhigh := rsecondmark
end if
end if
if rsecondmark < rthirdmark then
if rsecondmark > rfirstmark then
rsecondhigh := rsecondmark
end if
end if
if rsecondmark < rfirstmark then
if rsecondmark < rthirdmark then
rthirdhigh := rsecondmark
end if
end if
if rsecondmark < rthirdmark then
if rsecondmark < rfirstmark then
rthirdhigh := rsecondmark
end if
end if
if rthirdmark > rfirstmark then
if rthirdmark > rsecondmark then
rfirsthigh := rthirdmark
end if
end if
if rthirdmark > rsecondmark then
if rthirdmark > rfirstmark then
rfirsthigh := rthirdmark
end if
end if
if rthirdmark < rfirstmark then
if rthirdmark > rsecondmark then
rsecondhigh := rthirdmark
end if
end if
if rthirdmark < rsecondmark then
if rthirdmark > rfirstmark then
rsecondhigh := rthirdmark
end if
end if
if rthirdmark < rfirstmark then
if rthirdmark < rsecondmark then
rthirdhigh := rthirdmark
end if
end if
if rthirdmark < rsecondmark then
if rthirdmark < rfirstmark then
rthirdhigh := rthirdmark
end if
end if
raverage := (rfirsthigh + rsecondhigh) / camount
%Output
put "The average of the two highest marks is " ..
put raverage
Мне нужен способ сократить часть процесса без использования и / или (потому что это то, что сказал наш учитель).