Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { paulogp }
- { mac os 7 }
- program Ada18p;
- uses
- MemTypes, QuickDraw, OSIntf;
- const
- MAX = 10;
- type
- indice = 1..MAX;
- vector = array[indice] of real;
- var
- tecla: string;
- n: indice;
- vn: vector;
- procedure lenum(var n: indice);
- begin
- repeat
- writeln;
- write('Introduza um número Par (n in [1;', MAX, ']): ');
- readln(n);
- if (n < 1) or (n > MAX) or (odd(n) = true) then
- begin
- writeln;
- writeln('Leia com atenção o que lhe é pedido!');
- end;
- until (n >= 1) and (n <= MAX) and (odd(n) = false);
- end;
- procedure constroivector(var v: vector; n: indice);
- var
- temp: integer;
- begin
- temp:= 1;
- while temp <= n do
- begin
- writeln;
- write('Escreva um número real: ');
- readln(v[temp]);
- temp:= temp + 1;
- end;
- end;
- procedure maxminvector(v: vector; n: indice);
- var
- i, k: Integer;
- aux, maximo, minimo: real;
- begin
- k:= n;
- clearscreen;
- gotoxy(35, 2);
- writeln('Tabela');
- gotoxy(35, 3);
- writeln('------');
- writeln;
- writeln;
- for i:= 1 to (n div 2) do write(v[i]:2:0,' ');
- write(' | ');
- for i:= (n div 2) + 1 to n do write(v[i]:2:0,' ');
- for i:= 1 to (n div 2) do
- begin
- if v[i] > v[k] then
- begin
- aux:= v[i];
- v[i]:= v[k];
- v[k]:= aux;
- end;
- k:= k - 1;
- end;
- writeln;
- writeln;
- for i:= 1 to (n div 2) do write(v[i]:2:0, ' ');
- write(' | ');
- for i:= (n div 2) + 1 to n do write(v[i]:2:0, ' ');
- writeln;
- writeln;
- writeln;
- maximo:= v[1];
- minimo:= v[1];
- for i:= 1 to n do
- begin
- if (i>=(n div 2)) and (v[i] > maximo) then maximo:= v[i] else
- if v[i] < minimo then minimo:= v[i];
- end;
- writeln;
- writeln('Máximo vector: ', maximo:3:3);
- writeln;
- writeln('Mínimo vector: ', minimo:3:3);
- end;
- begin
- repeat
- clearscreen;
- gotoxy(25, 2);
- writeln('Cálculo do Máximo e Mínimo');
- gotoxy(25, 3);
- writeln('--------------------------');
- gotoxy(34, 4);
- writeln('Paulo G.P.');
- writeln;
- lenum(n);
- constroivector(vn, n);
- writeln;
- maxminvector(vn, n);
- writeln;
- writeln;
- writeln;
- write('Repetir (s/n): ');
- readln(tecla);
- uprstring(tecla, true);
- until tecla = 'N';
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement