Answer the question
In order to leave comments, you need to log in
What does this line do in pascal?
What does the second for do, why is ord here and why subtract 48?
procedure StrToMass(var a:mass; var s:string);
var i:integer;
begin
for i:=1 to 9 do
a[i]:=0;
for i:=1 to length(s) do
inc(a[ord(s[i])-48]);
end;
Answer the question
In order to leave comments, you need to log in
The second for makes a pass through the characters of the string and, as far as I understand, counts the number of characters from 0 to 9. Ord is needed in order to convert the character into a numeric value according to the ascii table, and 48 is taken away, because the numbers in this table start just from 48.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question