TwojePC.pl © 2001 - 2025
|
 |
A R C H I W A L N A W I A D O M O Ś Ć |
 |
|
|
Zamiana dec na bin i odwrotnie w pascalu. , laciak88 12/06/06 17:17 Jako, ze masta w pascalu nie jestem, to zwracam sie do was z prosba. Musze napisac na srode program na zaliczenie z infy o funkcjonalnosci jak w temacie i potrzebuje waszej pomocy. Jak w pascalu napisac najszybszy algorytm zamiany liczb dzietnych na binarne i odwrotnie? Prosze pomozcie mi, nakierujcie, podpowiedzcie. Z gory dziex!"To Alcohol! The cause of, and solution to, all of
life's problems." - http://groups.google.pl/group/borland.public.delphi.objectpascal/browse_thread/thread/ea28 , tebe 12/06/06 18:32
<untested>
function bin2int (s : string) : integer;
var i : integer;
begin
result := 0;
for i := 1 to length(s) do begin
result := 2*result;
if s[i] = '1' then inc(result);
end;
end;
function int2bin (n : integer) : string;
var i : integer;
begin
if n = 0 then result := '0'
result := '';
while n > 0 do begin
if odd(n) then result := result + '1'
result := result + '0';
n := n div 2;
end;
end;- widzialem to , laciak88 12/06/06 18:35
ale nie mam za cholere pojecia jak to wczepic do programu zeby dzialalo. Tzn jak dopisac reszte programu zeby to wszystko ruszylo. Nie uwazalo sie na infie i sie teraz ma :/. Wiesz jak to opisac?"To Alcohol! The cause of, and solution to, all of
life's problems." - Wczepić jako funkcje... , Umek 12/06/06 23:21
j.w. (lol) :-)
|
|
|
|
 |
All rights reserved ® Copyright and Design 2001-2025, TwojePC.PL |
 |
|
|
|