Добавил:
Silebox
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
program lab5_dop_var2;
const n = 203;
var
i, j, temp_pos: byte;
max_str: shortstring = '';
s: shortstring;
begin
for i:=1 to n do
begin
// Формируем строку
s := '';
for j:=1 to n do s := s + '1';
insert('2',s,i);
while ((pos('111',s) <> 0) or (pos('222',s) <> 0)) do
begin
if (pos('111',s) <> 0) then
begin
temp_pos := pos('111',s);
delete(s,temp_pos,3);
insert('22',s,temp_pos);
end
else
begin
temp_pos := pos('222',s);
delete(s,temp_pos,3);
insert('11',s,temp_pos);
end;
end;
if (length(s) > length(max_str)) then max_str := s;
end;
WriteLn(max_str);
end.
const n = 203;
var
i, j, temp_pos: byte;
max_str: shortstring = '';
s: shortstring;
begin
for i:=1 to n do
begin
// Формируем строку
s := '';
for j:=1 to n do s := s + '1';
insert('2',s,i);
while ((pos('111',s) <> 0) or (pos('222',s) <> 0)) do
begin
if (pos('111',s) <> 0) then
begin
temp_pos := pos('111',s);
delete(s,temp_pos,3);
insert('22',s,temp_pos);
end
else
begin
temp_pos := pos('222',s);
delete(s,temp_pos,3);
insert('11',s,temp_pos);
end;
end;
if (length(s) > length(max_str)) then max_str := s;
end;
WriteLn(max_str);
end.
Соседние файлы в папке лаб5