для †Neverdream† |
uses crt;
function BinToOct(s:string):string;
var s4,s3 : string;
begin
s4:='';
s3:='';
while s<>'' do begin
s3:=copy(s,1,3);
delete(s,1,3);
if s3='000'then s4:=s4+'0';
if s3='001'then s4:=s4+'1';
if s3='010'then s4:=s4+'2';
if s3='011'then s4:=s4+'3';
if s3='100' then s4:=s4+'4';
if s3='101' then s4:=s4+'5';
if s3='110' then s4:=s4+'6';
if s3='111' then s4:=s4+'7';
end;
while s4[1]='0' do delete(s4,1,1);
BinToOct:=s4;
end;
var i : integer;
s,s1 : string;
begin
clrscr;
write('input string ');
readln(s);
i:=0;
s1:='';
while s<>''do
begin
inc(i);
if (s[i]='1') or (s[i]='0') then s1:=s1+s[i]
else begin
delete(s,1,i);
i:=0;
while length(s1) mod 3<>0 do
s1:='0'+s1;
writeln(BinToOct(s1));
s1:='';
end;
if (s[1]<>'1') and (s[1]<>'0') then begin
delete(s,1,1);
i:=0;
end;
end;
readln;
end.
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |