uses crt; var a:array[1..1000] of longint; i,n:word; procedure xuly; var nho1:byte;nho2:string[2];st:string; begin st:=”; while a[i]<>0 do begin nho1:=a[i] mod 2; a[i]:=a[i] div 2; str(nho1,nho2); st:=nho2+st; end; writeln(st); end; begin clrscr; readln(n); for i:=1 to n do readln(a[i]); for i:=1 to n do xuly; readln; end.
program chuyen_nhi_phan;
uses crt;
var A:array[1..1000] of integer;
n,i:integer;
{—Ham-chuyen-nhi-phan—}
function nhiphan(k:integer):string;
var st,s:string;
begin
nhiphan:=”;
if (k=0) or (k=1) then str(k,st)
else
while k>0 do
begin
str(k mod 2,s);
st:=s+st;
k:=k div 2;
end;
nhiphan:=st;
end;
{—Chuong-trinh-chinh—}
BEGIN
clrscr;
write(‘Nhap so luong phan tu: ‘); readln(n);
for i:=1 to n do
begin
write(‘Nhap so thu ‘,i,’: ‘); readln(A[i]);
end;
writeln(‘Chuyen sang nhi phan theo thu tu:’)
for i:=1 to n do
writeln(A[i],’ = ‘,nhiphan(A[i]));
readln;
end.
uses crt;
var a:array[1..1000] of longint;
i,n:word;
procedure xuly;
var nho1:byte;nho2:string[2];st:string;
begin
st:=”;
while a[i]<>0 do
begin
nho1:=a[i] mod 2;
a[i]:=a[i] div 2;
str(nho1,nho2);
st:=nho2+st;
end;
writeln(st);
end;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do xuly;
readln;
end.