Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 6 odgovora
  • 4.891 pregleda

Najnovija ↓

Zasto u pascalu radi, a u delphiu ne radi??? :( 21.06.2005. u 15:37 · pre 260 meseci #1
Evo, program koji obican broj pretvori u binarni....prilagodjen pascalu savrseno radi, al u delphi nece (vjerujem da je problem kod:for j:=i downto 1 do Edit4.Text:=binarni[j])...........

Code:

procedure TForm1.Button5Click(Sender: TObject);
var br:integer;
    i,ost,j:byte;
    binarni:string;
begin
br:=StrToInt(Edit3.Text);
i:=0;
ost:=0;
while br>0 do
begin
i:=i+1;
ost:=br mod 2;
if ost=0 then binarni:='0'
         else binarni:='1';
br:=br div 2;
for j:=i downto 1 do
begin
Edit4.Text:=binarni[j];
end;
end;
end;


:( :( :(
Re: Zasto u pascalu radi, a u delphiu ne radi??? :( 21.06.2005. u 16:02 · pre 260 meseci #2
Code:

var br:integer;
    i,ost,j:byte;
    binarni:string;
begin
  br:=StrToInt(Edit3.Text);
  i:=0;
  ost:=0;
  while br>0 do
  begin
    i:=i+1;
    ost:=br mod 2;
    if ost=0 then binarni := '0' + binarni
             else binarni := '1' + binarni;
    br:=br div 2;
  end;

  Edit4.Text := binarni;
end;

Pozdrav!
Re: Zasto u pascalu radi, a u delphiu ne radi??? :( 21.06.2005. u 16:53 · pre 260 meseci #4
A kako bi izgledao kod za pretvaranje obicnog u heksadekatski.....ali opet ne radi
:(

Code:

procedure TForm1.Button6Click(Sender: TObject);
var broj:longint;
    ost,i,j:byte;
    heksa:string;
begin
broj:=StrToInt(Edit5.Text);
i:=0;
while broj>0 do
begin
i:=i+1;
ost:=broj mod 16;

if ost=1 then heksa:='1'+heksa;
if ost=2 then heksa:='2'+heksa;
if ost=3 then heksa:='3'+heksa;
if ost=4 then heksa:='4'+heksa;
if ost=5 then heksa:='5'+heksa;
if ost=6 then heksa:='6'+heksa;
if ost=7 then heksa:='7'+heksa;
if ost=8 then heksa:='8'+heksa;
if ost=9 then heksa:='9'+heksa;
if ost=10 then heksa:='A'+heksa;
if ost=11 then heksa:='B'+heksa;
if ost=12 then heksa:='C'+heksa;
if ost=13 then heksa:='D'+heksa;
if ost=14 then heksa:='E'+heksa;
if ost=15 then heksa:='F'+heksa;

end;

broj:=broj div 16;
Edit6.Text:=heksa;
end;
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme