| Код | const delimiter = [#32, ',']; type TWords = array[1 .. 50] of string;
function GetWords(s: string; var words: TWords): integer; var i, back, n: integer; begin i := 1; n := 0; while i <= length(s) do begin
while (i <= length(s)) and (s[i] in delimiter) do inc(i); if i <= length(s) then begin back := i; while (i <= length(s)) and not(s[i] in delimiter) do inc(i); inc(n); words[n] := copy(s, back, i - back); end; end; GetWords := n; end;
var s: string; words: TWords; i: integer;
begin write('s = '); readln(s); for i := GetWords(s, words) downto 1 do writeln(words[i]); end. |
? |