遍历吧var x : boolean; arr : array[0..10] of boolean; i : integer; begin x := true; for i := 0 to length(arr) do arr[i] := true; for i:= 0 to length(arr) do begin if arr[i] = false then begin x := false; break; end; end; if x = true then showmessage('全部为true'); end;
var alltrue,allfalse:boolean; arr : array of boolean; begin alltrue := true; allfalse := false; for i:= low(arr) to high(arr) do begin alltrue := alltrue and arr[i]; allfalse := allfalse or arr[i]; end; if alltrue then showmessage('全真!'); if not allfalse then showmessage('全假!'); end;
var alltrue,notallfalse:boolean; arr : array of boolean; begin alltrue := true; notallfalse := false; for i:= low(arr) to high(arr) do begin alltrue := alltrue and arr[i]; notallfalse := notallfalse or arr[i]; if (not alltrue) and (notallfalse) break; end; if alltrue then showmessage('全真!'); if not notallfalse then showmessage('全假!'); end;
x : boolean;
arr : array[0..10] of boolean;
i : integer;
begin
x := true;
for i := 0 to length(arr) do
arr[i] := true;
for i:= 0 to length(arr) do
begin
if arr[i] = false then
begin
x := false;
break;
end;
end;
if x = true then
showmessage('全部为true');
end;
各个元素依次or 操作,如果为1,则退出;
alltrue,allfalse:boolean;
arr : array of boolean;
begin
alltrue := true;
allfalse := false;
for i:= low(arr) to high(arr) do
begin
alltrue := alltrue and arr[i];
allfalse := allfalse or arr[i];
end;
if alltrue then showmessage('全真!');
if not allfalse then showmessage('全假!');
end;
alltrue,notallfalse:boolean;
arr : array of boolean;
begin
alltrue := true;
notallfalse := false;
for i:= low(arr) to high(arr) do
begin
alltrue := alltrue and arr[i];
notallfalse := notallfalse or arr[i];
if (not alltrue) and (notallfalse) break;
end;
if alltrue then showmessage('全真!');
if not notallfalse then showmessage('全假!');
end;