Var n,i,j,k,s,sn:integer;
begin
writeln('n = ');
readln(n);
sn:=round(sqrt(n));
for i:=1 to sn do
for j:=1 to sn do
for k:=1 to sn do
begin
s:=i*i+j*j+k*k;
if s=n then writeln(i,'^2+',j,'^2+',k,'^2 = ',s);
end;
end.
Пример:
n = 253
3^2+10^2+12^2 = 253
3^2+12^2+10^2 = 253
10^2+3^2+12^2 = 253
10^2+12^2+3^2 = 253
12^2+3^2+10^2 = 253
12^2+10^2+3^2 = 253