Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses crt;
- var
- a:array[1..100] of longint;
- i,n,x,y:longint;
- function check(bool:boolean):longint;
- var tmp,max:longint;
- begin
- tmp:=1;
- max:=1;
- for i:=2 to n do
- if ((a[i] > a[i-1] = bool) or (a[i] = a[i-1])) then
- begin
- inc(tmp);
- if tmp>max then max:=tmp;
- end
- else tmp:=1;
- check:=max;
- end;
- procedure sort(bool:boolean);
- var j,temp:longint;
- begin
- for i:=1 to n do
- for j:=i+1 to n do
- if ((a[i] > a[j] = bool) or (a[i] = a[j])) then
- begin
- temp:=a[i];
- a[i]:=a[j];
- a[j]:=temp;
- end;
- end;
- procedure rwArray(bool:boolean);
- begin
- if bool then readln(n);
- for i:=1 to n do
- if bool then read(a[i])
- else write(a[i],' ');
- if bool then readln();
- end;
- begin
- clrscr();
- rwArray(true);
- x:=check(true);
- y:=check(false);
- if x<>y then sort(x>y);
- rwArray(false);
- readln();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement