Localize file www.TrSek.com/zadania/cis_stv.pas
{ CIS_STV.PAS               Copyright (c) TrSek alias Zdeno Sekerak }
{ Je zname, ze lubovolne prirodzene cislo mozno vyjadrit ako sucet  }
{ styroch stvorcov nazapornych cisel. Najdite taketo vyjadrenia pre }
{ vsetky cisla mensie ako dane n.                                   }
{                                                                   }
{ Datum:23.05.2004                             http://www.trsek.com }

program stvorce_cisel;
var i,s:integer; { pre slucky }
    n:integer;   { cislo n }
    zb:integer;  { zbytok po deleni }
    cc:integer;  { jednotlive stvorce }

begin
  WriteLn('Rozlozim cislo na sucet 4 stvorcov nezapornych cisel.');
  Write ('Zadaj cislo n:');
  ReadLn(n);

  { pre vsetky cisla zaradom }
  for i:=1 to n do begin
    Write(i:3,'=>');
    zb:=i;

    { zisti stvorce }
    for s:=1 to 4 do begin
      cc:=Trunc(sqrt(zb));
      zb:=zb-(cc*cc);
      Write(cc,',');
    end;
    WriteLn;

  end;

  ReadLn;
end.

Copyrigth by Zdeno Sekerak 2007, http://www.trsek.com