Enemy_vn Posted March 29, 2010 Report Share Posted March 29, 2010 помогите пожалуста доделать программу что бы она с дробами работала var I:Integer; C:Char; Si,So:String; St:String[3]; const S:array['0'..'7'] of String[3]=('000','001','010','011','100','101','110','111'); begin ReadLn(Si); while Length(Si) mod 3 <> 0 do Si:='0'+Si; { доп. строку влево до длины, кратной 3 } So:=''; for I:=1 to Length(Si) div 3 do begin St:=Copy(Si,3*I-2,3); { 3*I-2 дает числа 1,4,7... - нач. позиции троек дв. цифр } for C:='0' to '7' do if St=S[C] then So:=So+C end; Writeln(So); end. ето прога для перевода из 2СС в 8СС пы. сы. СС - система счисления)))))) Quote Link to comment Share on other sites More sharing options...
Тролль Posted March 30, 2010 Report Share Posted March 30, 2010 Enemy_vn: var i:integer; C:char; Fi,Fo,Si,So,Mi,Mo:string; St:string[3]; P:boolean;const S:array['0'..'7']of string[3]=('000','001','010','011','100','101','110','111');beginreadln(Fi); P:=Fi[1]='-'; if P or(Fi[1]='+') then delete(Fi,1,1); i:=pos('.',Fi); if i=0 then begin Fi:=Fi+'.'; i:=length(Fi) end;Si:=copy(Fi,1,i-1); Mi:=copy(Fi,i+1,length(Fi)-i); So:=''; Mo:='';while length(Si) mod 3 <> 0 do Si:='0'+Si; while length(Mi) mod 3 <> 0 do Mi:=Mi+'0';for i:=1 to length(Si) div 3 do begin St:=copy(Si,3*I-2,3); for C:='0' to '7' do if St=S[C] then So:=So+C end;for i:=1 to length(Mi) div 3 do begin St:=copy(Mi,3*I-2,3); for C:='0' to '7' do if St=S[C] then Mo:=Mo+C end;if length(Mo)=0 then Fo:=So else Fo:=So+'.'+Mo; if P then Fo:='-'+Fo; writeln(Fo); readlnend. Разделительный знак - точка. Quote Link to comment Share on other sites More sharing options...
Enemy_vn Posted March 30, 2010 Author Report Share Posted March 30, 2010 пасибо огромное)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.