pascal :got "boolean" expected "longint"var n,p,q,i,k,j:longint;t2:boolean; t1:boolean ;beginreadln(n);p:=1;repeatp:=p+1;q:=n-p;t1:=true;for i:=2 to trunc(sqrt(p)) doif p mod j=0 then begin t1:=false; k:=k+1;end;t2:=true;for i:=2 to trunc(sqrt(q)) do
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 20:25:37
pascal :got "boolean" expected "longint"var n,p,q,i,k,j:longint;t2:boolean; t1:boolean ;beginreadln(n);p:=1;repeatp:=p+1;q:=n-p;t1:=true;for i:=2 to trunc(sqrt(p)) doif p mod j=0 then begin t1:=false; k:=k+1;end;t2:=true;for i:=2 to trunc(sqrt(q)) do
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 "boolean" expected "longint"var n,p,q,i,k,j:longint;t2:boolean; t1:boolean ;beginreadln(n);p:=1;repeatp:=p+1;q:=n-p;t1:=true;for i:=2 to trunc(sqrt(p)) doif p mod j=0 then begin t1:=false; k:=k+1;end;t2:=true;for i:=2 to trunc(sqrt(q)) do
倒数第二行t1 and t2 and k=n 错了
改为 t1 and t2 and (k=n);
不然t2会和k比较,boolean 不能和int比较