V
V
Viktor2020-05-25 21:07:17
Pascal
Viktor, 2020-05-25 21:07:17

What does the line min := i mean?

What does the line min := i mean?
program choiсesort;
var mas: array[1..5] of integer; j, i, min, obmen, gen: integer;
begin
  randomize;
  for gen:=1 to 5 do mas[gen]:=random(1, 10);
  writeln(mas);
  
  for i:=1 to 4 do begin
    min := i; {<----- почему мы присваиваем минимуму значение i ?}
    
    for j:=i to 5 do if mas[j] < mas[min] then min:=j;
    
    if min <> i then begin
      obmen := mas[i];
      mas[i]:=mas[min];
      mas[min]:=obmen;
      writeln(mas);
    end;
  end; 
end.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2020-05-25
@SagePtr

https://ru.wikipedia.org/wiki/%D0%A1%D0%BE%D1%80%D...

H
HemulGM, 2020-05-26
@HemulGM

This is someone else's code. What he wanted to do with it and how it works, no one knows. Just read the steps one by one and try to figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question