主题:分解质因数程序为何出错?
分解质因数程序为何出错?
program fenjie;
type a=array[1..50] of integer; {类型有错吗?}
var i,q,w,x:integer;
begin
readln(w);
for q:=1 to 50 do a[q]:=0; {这句错什么了?}
q:=1;
for x:=2 to 100 do
begin
i:=2;
while i<= sqrt(x) and (x mod i <>0) do inc(i);
if i>sqrt(x) then
begin
a[q]:=x;
inc(q);
end;
end;
q:=1;
repeat
if w mod a[q]=0 then
begin
w:=w div a[q];
writeln(a[q]);
end;
inc(q);
until w=1;
end.
编写程序的时候总是出错...
program fenjie;
type a=array[1..50] of integer; {类型有错吗?}
var i,q,w,x:integer;
begin
readln(w);
for q:=1 to 50 do a[q]:=0; {这句错什么了?}
q:=1;
for x:=2 to 100 do
begin
i:=2;
while i<= sqrt(x) and (x mod i <>0) do inc(i);
if i>sqrt(x) then
begin
a[q]:=x;
inc(q);
end;
end;
q:=1;
repeat
if w mod a[q]=0 then
begin
w:=w div a[q];
writeln(a[q]);
end;
inc(q);
until w=1;
end.
编写程序的时候总是出错...