Ta spirala:
program slimak;
uses
SysUtils;
var
tablica : array of array of integer;
x, y, spdX, spdY, i, n : integer;
begin
spdX := 1;
spdY := 0;
Write('Podaj rozmiar tablicy : ');
Readln(n);
SetLength(tablica, n, n);
for y := 0 to n-1 do
for x := 0 to n-1 do
tablica[x,y] := 0;
x := 0;
y := 0;
for i := 1 to n*n do
begin
if (x+spdX>n-1)or(y+spdY>n-1)or(x+spdX<0)or(y+spdY<0)or(tablica[x+spdX,y+spdY] <> 0) then
begin
if (spdX=1)and(spdY=0) then
begin
spdX := 0;
spdY := 1;
end else
if (spdX=0)and(spdY=1) then
begin
spdX := -1;
spdY := 0;
end else
if (spdX=-1)and(spdY=0) then
begin
spdX := 0;
spdY := -1;
end else
if (spdX=0)and(spdY=-1) then
begin
spdX := 1;
spdY := 0;
end;
end;
tablica[x,y] := i;
x := x + spdX;
y := y + spdY;
end;
for y := 0 to n-1 do
begin
for x := 0 to n-1 do
write(tablica[x,y],#9);
write(tablica[x,y],#9);
end;
end.
Calka: (wersja x poczatkowy i x koncowy)
program project10;
uses crt;
var
x, xp, xk : real;
calka,h : real;
function funkcja(x:real):real;
begin
funkcja:=sqr(x);
end;
begin
clrscr;
writeln('podaj xp i xk (x poczatkowy i x koncowy)');
write('xp=');
read(xp);
write('xk=');
read(xk);
h:=(xk-xp)/2;
calka:=(xk-xp)*funkcja(h);
writeln('calka=',calka:5:5);
readkey;
end.