Pascal/Turbo Pascal - Problema basico y tonto :s

 
Vista:

Problema basico y tonto :s

Publicado por Sebastian (2 intervenciones) el 14/10/2010 04:36:40
Les comento el problema es el siguiente tengo q encontrar el mayor entre 5 numeros pero tiene q respetar la forma de uno q tiene 3 variables:
Aqui la forma del q tiene 3 variables:

If x>=y then
if x>=z then max:=x
else max:=z
else if y>=z then max:=y
else max:=z;

lo probe en pascal y obio anda exelente, ahora cuando ago uno similar con 5 variables solo encontra el max cuando el x es el mayor, cuando pruebo q otro sea el mayor pascal me tira "el mayor es 0"

program prueba;
uses crt;
var x,y,z,w,t,max:integer;
begin
clrscr;
write(' Ingrese Num: '); readln(x);
write(' Ingrese Num: '); readln(y);
write(' Ingrese Num: '); readln(z);
write(' Ingrese Num: '); readln(w);
write(' Ingrese Num: '); readln(t);
if x>=y then
if x>=z then
if x>=w then
if x>=t then max:=x
else max:=t
else if y>=z then
if y>=w then
if y>=t then max:=y
else max:=t
else if z>=w then
if z>=t then max:=z
else max:=t
else if w>=t then max:=w
else max:=t;
writeln(' El mayor es: ',max);
readkey;
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Problema basico y tonto :s

Publicado por c (3 intervenciones) el 04/11/2010 17:41:11
mayor:=x
if y>mayor then mayor:=y;
if z>mayor then mayor:=z;
if w>mayor then mayor:=w;
if t>mayor then mayor:=t;

writeln(' El mayor es: ',mayor);
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar