请问有人知道怎样求2000内的勾股数吗?要turbo pascal编程的

来源:百度知道 编辑:UC知道 时间:2024/05/08 20:40:18

program gougu;
var
i,a,b,c,d:integer;
begin
d:=0;
for a:=1 to 2000 do
for b:=1 to 2000 do
for c:=1 to 2000 do
if (a*a+b*b=c*c) and (a<c) and (b<c) and (c<2000)
then
begin
d:=d+1;
write(a:5,b:5,c:5);
if (d mod 6=0) then writeln;
readln;
end;
end.

这是我自己写的,我试用过了,绝对正确!!!
(注:看数字的时候要按回车),你慢慢看吧...

program gougu;
var
a,b,c,d:integer;
begin
d:=0;
for a:=1 to 2000 do
for b:=a+1 to 2000 do
for c:=b+1 to 2000 do
if (a*a+b*b=c*c) then
begin
d:=d+1;
write(a:5,b:5,c:5);
if (d mod 4=0) then writeln;
end;
end.
时间省

program Ggs
var
a,b,c:integer;
begin
assign(input,'Ggs.txt');
reset(input);
for a:=1 to 1998 do
for b:=a to 2000 do
if round(sqrt(a*a+