Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program pliki1;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes,sysutils;
- { you can add units after this }
- var
- bin :string;
- plik1,plik2:TextFile;
- dzies : qword;
- procedure zamien(bin:string; var liczba:qword) ;
- var
- i,k,pot:integer;
- begin
- pot:=2;
- if bin[length(bin)]='0' then liczba:=0;
- if bin[length(bin)]='1' then liczba:=1;
- for i:=length(bin)-1 downto 1 do
- begin
- k:=StrToInt(bin[i]);
- liczba:=liczba+pot*k ;
- pot:=pot*2;
- end;
- end;
- begin
- assignfile(plik1,'binarne.txt');
- assignfile(plik2,'pokonw.txt');
- reset(plik1);
- rewrite(plik2);
- while not EoF(plik1) do
- begin
- readln(plik1,bin);
- zamien(bin,dzies);
- writeln(plik2, bin, dzies:50);
- end;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement