The document describes procedures for manipulating arrays in Pascal:
1) A procedure to shift an array to the right by moving the first element to the last index.
2) A procedure to invert an array by assigning elements in reverse order.
3) Procedures to find the minimum, maximum, and average values of an array by iterating through its elements.
The document describes procedures for manipulating arrays in Pascal:
1) A procedure to shift an array to the right by moving the first element to the last index.
2) A procedure to invert an array by assigning elements in reverse order.
3) Procedures to find the minimum, maximum, and average values of an array by iterating through its elements.
The document describes procedures for manipulating arrays in Pascal:
1) A procedure to shift an array to the right by moving the first element to the last index.
2) A procedure to invert an array by assigning elements in reverse order.
3) Procedures to find the minimum, maximum, and average values of an array by iterating through its elements.
The document describes procedures for manipulating arrays in Pascal:
1) A procedure to shift an array to the right by moving the first element to the last index.
2) A procedure to invert an array by assigning elements in reverse order.
3) Procedures to find the minimum, maximum, and average values of an array by iterating through its elements.
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;