Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. program pliki1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6. {$IFDEF UNIX}{$IFDEF UseCThreads}
  7. cthreads,
  8. {$ENDIF}{$ENDIF}
  9. Classes,sysutils;
  10.  
  11. { you can add units after this }
  12.  
  13. var
  14. bin :string;
  15. plik1,plik2:TextFile;
  16. dzies : qword;
  17.  
  18. procedure zamien(bin:string; var liczba:qword) ;
  19. var
  20. i,k,pot:integer;
  21. begin
  22. pot:=2;
  23. if bin[length(bin)]='0' then liczba:=0;
  24. if bin[length(bin)]='1' then liczba:=1;
  25. for i:=length(bin)-1 downto 1 do
  26. begin
  27. k:=StrToInt(bin[i]);
  28. liczba:=liczba+pot*k ;
  29.  
  30. pot:=pot*2;
  31. end;
  32. end;
  33.  
  34.  
  35.  
  36.  
  37. begin
  38. assignfile(plik1,'binarne.txt');
  39. assignfile(plik2,'pokonw.txt');
  40. reset(plik1);
  41. rewrite(plik2);
  42. while not EoF(plik1) do
  43. begin
  44. readln(plik1,bin);
  45. zamien(bin,dzies);
  46. writeln(plik2, bin, dzies:50);
  47. end;
  48. readln;
  49. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement