practica 7 ejercicio 7
program HelloWorld;
const
bits=64;
type
rangoBits = 1 .. bits;
Tvector = array [rangoBits] of boolean;
function operandoAnd(a,b:boolean):boolean;
begin
if a then begin
if b then begin
operandoAnd := true;
end else
operandoAnd := false;
end else operandoAnd:= false;
end;
function operandoOr(a,b:boolean):boolean;
begin
if a then begin
operandoOr:=true;
end else
if b then begin
operandoOr:=true;
end else
operandoOr:= false;
end;
function operandoNot(a:boolean):boolean;
begin
if a then begin
operandoNot:= false;
end else
operandoNot:=true;
end;
function rand():boolean;
var
n:integer;
begin
n := random(50);
if n mod 2 = 0 then begin
rand := true;
end else
rand:=false;
end;
procedure mostrarVector(v:Tvector);
var
i:rangoBits;
begin
for i:=1 to bits do
write('--');
writeln;
for i:=1 to bits do
if v[i] then begin
write('|1');
end else
write('|0');
writeln('|');
for i:=1 to bits do
write('--');
end;
var
i:integer;
v:Tvector;
a,b:boolean;
begin
i:=1;
a:= true;
b:= false;
randomize;
while i <= bits do begin
v[i]:= operandoAnd(a,b);
i:= i+1;
if i <= bits then begin
v[i]:= operandoOr(a,b);
i:= i+1;
if i <= bits then
v[i]:=operandoNot(a);
end;
a:=rand();
write('a: ',a,' ');
b:=rand();
writeln('b: ',b);
end;
mostrarVector(v);
end.
|
run
| edit
| history
| help
|
0
|
|
|