sábado, 7 de septiembre de 2013

Algoritmo para obtener los valores máximo y mínimo de un conjunto de números

program maxmin;
uses crt;

var x,xx: array [1..10] of real;
var max,min:real;
var i:integer;

begin
  clrscr;


  for i:=1 to 10 do
    begin
      write('x[',i,']=');readln(x[i]);
    end;



  max:=x[1];
  min:=x[1];
  for i:=1 to 10 do
    begin
      if x[i]>max then max:=x[i];
      if x[i]<min then min:=x[i];
    end;


  writeln('el valor m…xim ‚s: ',max);
  writeln('el valor m¡nim ‚s: ',min);

  repeat until keypressed;


end.

[autoría]