Добавил:
Silebox
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
program var1;
var
i: byte = 1;
result,j,temp_pos: byte;
s: ansistring;
function StrtoInt(Str: string): integer;
var
I,C: integer;
begin
val(Str,I,C);
if C<>0 then I:=0;
StrToInt:=I;
end;
begin
while (result <> 34) do
begin
s := '';
result := 0;
for j:=1 to 10 do s := concat(s,'1');
for j:=1 to i do s := concat(s,'2');
while (pos('21',s) <> 0) do
begin
temp_pos := pos('21',s);
delete(s,temp_pos,2);
insert('5',s,temp_pos);
end;
for j:=1 to length(s) do result := result + StrToInt(s[j]);
inc(i);
end;
WriteLn(i);
end.
var
i: byte = 1;
result,j,temp_pos: byte;
s: ansistring;
function StrtoInt(Str: string): integer;
var
I,C: integer;
begin
val(Str,I,C);
if C<>0 then I:=0;
StrToInt:=I;
end;
begin
while (result <> 34) do
begin
s := '';
result := 0;
for j:=1 to 10 do s := concat(s,'1');
for j:=1 to i do s := concat(s,'2');
while (pos('21',s) <> 0) do
begin
temp_pos := pos('21',s);
delete(s,temp_pos,2);
insert('5',s,temp_pos);
end;
for j:=1 to length(s) do result := result + StrToInt(s[j]);
inc(i);
end;
WriteLn(i);
end.