N
N
Nika2018-11-12 12:07:50
Pascal
Nika, 2018-11-12 12:07:50

What happens in a procedure? And why is the minimum 256?

procedure MasToStr(var a: mas; var res: string);//формирование результирующей строки по массиву
var
   min: integer;
   k: string; c: char;
begin
   res := '';
   min := 256;
   for c := 'A' to 'Z' do
      if (a[c] > 0)  and (a[c] < min) then begin //если буква встретилась
         min := a[c];
         k := c;
      end;
   if (min < 256) then 
      res := ('Буква ' + k + ' встретилась ' + min + ' раз.')
end;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Melnikov, 2018-11-12
@glamurniy_kluben

It is better to insert the code as code - it is more convenient to read.
An array is passed to the procedure. Where, according to the indices corresponding to the character codes, there is a certain number. Judging by the context, the previously counted number of these characters. We find the symbol with the minimum number of occurrences and form an output string with a message about it.
Since the array seems to be characters, then the initial min is chosen so that any value in it is less than it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question