langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,39 @@
program LookAndSayDemo(input, output);
uses
SysUtils;
function LookAndSay (s: string): string;
var
item: char;
index: integer;
count: integer;
begin
LookAndSay := '';
item := s[1];
count := 1;
for index:= 2 to length(s) do
if item = s[index] then
inc(count)
else
begin
LookAndSay := LookAndSay + intTostr(count) + item;
item := s[index];
count := 1;
end;
LookAndSay := LookAndSay + intTostr(count) + item;
end;
var
number: string;
begin
writeln('Press RETURN to continue and ^C to stop.');
number := '1';
while not eof(input) do
begin
write(number);
readln;
number := LookAndSay(number);
end;
end.