作业帮 > 综合 > 作业

pascal :got "boolean" expected "longint"

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/16 17:20:59
pascal :got "boolean" expected "longint"
var n,p,q,i,k,j:longint;t2:boolean; t1:boolean ;
begin
readln(n);
p:=1;
repeat
p:=p+1;
q:=n-p;
t1:=true;
for i:=2 to trunc(sqrt(p)) do
if p mod j=0 then begin t1:=false; k:=k+1;end;
t2:=true;
for i:=2 to trunc(sqrt(q)) do
if q mod j=0 then t2:=false;
until t1 and t2 and k=n;
writeln(n,':=',p,'+',q);
end.
pascal :got
倒数第二行t1 and t2 and k=n 错了
改为 t1 and t2 and (k=n);
不然t2会和k比较,boolean 不能和int比较