Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const M = 1000000;
- var i, n, min, premin, max, premax: longint;
- a: array[1..M] of longint;
- begin
- read(n);
- for i := 1 to n do
- read(a[i]);
- min := M; premin := M;
- max := -M; premax := -M;
- for i := 1 to n do begin
- if a[i] < min then begin
- premin := min;
- min := a[i];
- end
- else if a[i] < premin then
- premin := a[i];
- if a[i] > max then begin
- premax := max;
- max := a[i];
- end
- else if a[i] > premax then
- premax := a[i];
- end;
- write('premin = ', premin, ', index = ');
- for i := 1 to n do
- if a[i] = premin then
- write(i, ' ');
- writeln;
- write('premax = ', premax, ', index = ');
- for i := 1 to n do
- if a[i] = premax then
- write(i, ' ');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement