Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit ArrayOpers;
- {-------------------------------------------------------------------------}
- interface
- procedure Swap(var a, b:longint);
- procedure FillArray(var arr : array of longint; arrsize, range: integer);
- procedure WriteArray(var arr : array of longint; arrsize:integer);
- procedure IsSorted(var arr : array of longint; arrsize:integer);
- procedure EquateArrays(var arr1, arr2 : array of longint; arrsize:integer);
- {-------------------------------------------------------------------------}
- implementation
- procedure Swap(var a, b:longint);
- var temp:integer;
- begin
- temp:= a;
- a:=b; b:=temp;
- end;
- procedure FillArray(var arr : array of longint; arrsize, range: longint);
- var i:longint;
- begin
- for i:= 0 to arrsize - 1 do
- arr[i]:= random(range);
- end;
- procedure WriteArray(var arr : array of longint; arrsize:integer);
- var i:integer;
- begin
- for i:= 0 to arrsize - 1 do
- write(arr[i],' ');
- writeln();
- end;
- procedure IsSorted(var arr : array of longint; arrsize : integer);
- var i:integer;
- flag:boolean;
- begin
- flag:= true;
- i:=1;
- while ((i < arrsize-1) and (flag)) do
- begin
- if (arr[i] <= arr[i+1]) then inc(i) else
- flag:=false;
- end;
- if (flag) then writeln('Sorted of inc') else
- begin
- i:=1;
- flag:= true;
- while ((i < arrsize-1) and (flag)) do
- begin
- if (arr[i] >= arr[i+1]) then inc(i) else
- flag:=false;
- end;
- if (flag) then writeln('Sorted of dec')
- else writeln('Not sorted');
- end;
- end;
- procedure EquateArrays(var arr1, arr2: array of longint; arrsize: integer);
- var i:integer;
- begin
- for i:= 0 to arrsize-1 do
- arr2[i]:=arr1[i];
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement