Вот задача:
Дана строка, состоящая из русских слов, разделенных пробелами (одним или
несколькими). Определить длину самого короткого|длинного слова.
Вот код:
uses crt;
type
TWords = Array [1..100] of String;
{-----------------------------------------------------}
Procedure GetWords(S : String; var mas : TWords; var count : Integer);
var i,j : Integer;
begin
i := 0;
for j := 1 to Length(S) do begin
if (j = 1) and (S[j] <> ' ') then
inc(i)
else if (j < Length(S)) and (S[j] = ' ') and (S[j + 1] <> ' ') then
inc(i);
if (S[j] <> ' ') then
mas[i] := mas[i] + S[j];
end;
count := i;
end;
{-----------------------------------------------------}
{-----------------------------------------------------}
Function LengthShortestWord(S: String) : Integer;
var i,count : Integer;
min : Integer;
mas : TWords;
begin
min := Maxint;
GetWords(S,mas,count);
for i := 1 to count do
if (Length(mas[i]) < min) then
min := Length(mas[i]);
LengthShortestWord := min;
end;
{-----------------------------------------------------}
var S : String;
begin
Clrscr;
WriteLn('Input String:');
ReadLn(S);
WriteLn('Length Shortest Word:');
WriteLn(LengthShortestWord(S));
ReadKey;
end.
Почему она возникает?