langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue