Procedure Nizovi: Procedura Za Pomeranje Udesno

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Procedure Nizovi

Procedura za pomeranje udesno

procedure TForm1.Button1Click(Sender: TObject);


var c,p:integer;
a:array[1..10] of integer;
begin
for c:=1 to 11- 1 do a[c]:=StrToInt (StringGrid1.Cells[c,1]);
p:=a[1];
for c:=2 to 11-1 do a[c-1]:=a[c];
a[11-1]:=p;
for c:=1 to 11-1 do StringGrid2.Cells [c,1]:=IntToStr (a[c]);
end;

Pise se 11-1 jer umanjujemo broj celija za 1 zbog zaglavlja!

Procedura za invertovanje niza

procedure TForm1.Button1Click(Sender: TObject);


var c:integer;
a:array [1..10] of integer;
begin
for c:=1 to 11-1 do a[c]:=strtoint (StringGrid1.Cells[c,1]);
for c:= 1 to 11-1 do StringGrid2.Cells [c,1]:=InttoStr(a[11-1-c+1]);
end;

Procedura za pronalazenje minimuma niza

procedure TForm1.Button1Click(Sender: TObject);


var c,min:integer;
a: array [1..10] of integer;
begin
for c:=1 to 11-1 do
a[c]:=StrToInt (StringGrid1.Cells [c,1]);
min:=a[1];
for c:=2 to 11-1 do
if a[c]< min then
min:=a[c];
edit1.text:=InttoStr(min);
end;

Procedura za pronalazenje maximuma niza

procedure TForm1.Button2Click(Sender: TObject);


var c,max:integer;
a: array [1..10] of integer;
begin
for c:=1 to 11-1 do
a[c]:=StrToInt (StringGrid1.Cells [c,1]);
max:=a[1];
for c:=2 to 11-1 do
if a[c]> max then
max:=a[c];
edit3.text:=InttoStr(max);
end;

Procedura za izracunavanje srednje vrednosti niza

procedure TForm1.Button3Click(Sender: TObject);


var S: real;
c:integer;
a: array[1..10] of integer;
begin
S:=0;
for c:=1 to 11-1 do
a[c]:=StrToInt (StringGrid1.Cells [c,1]);
for c:=1 to 11-1 do
begin
S:=S+a[c];
end;
S:=S / 10;
edit2.text:=FloatToStr(S);
end;

You might also like