Jump to content


Photo

Problema De Logica


  • Faça o login para participar
1 reply to this topic

#1 Ghost-Writer

Ghost-Writer

    Turista

  • Usuários
  • 44 posts
  • Sexo:Não informado

Posted 25/06/2004, 15:59

Ae galera, blz? Tipo, eu preciso entrega um trabalho hj noite, e naum to conseguindo resolve uma coisinha aparentemente simples:

Como pego 6 variaveis numéricas e vejo qual a maior? Estou usando este codigo, mas não mostra o valor verdadeiro:

procedure TForm1.moda;
var
maior : real;
fi : array[1..6] of real;
begin
fi[1]:= strtofloat(fi1.text);
fi[2]:=strtofloat(fi2.text);
fi[3]:=strtofloat(fi3.text);
fi[4]:=strtofloat(fi4.text);
fi[5]:=strtofloat(fi5.text);
fi[6]:=strtofloat(fi6.text);

maior:= 0;
if fi[1] > maior then
maior:=1;
if fi[2] > maior then
 maior:=2;
if (fi[3]) > maior then
maior:= 3;
if (fi[4]) > maior then
maior:=4;
if (fi[5]) > maior then
maior:=5;
if (fi[6]) > maior then
maior:=6;
showmessage(floattostr(maior));
end;

O resultado que aparece na showmessage eh sempre 5!

Podem me ajudar? Ah, e tipo, isso ae tah em delphi, mas se alguem coloca o codigo em qualquer otra linguagem tah blz, q eu entendo! O q naum to conseguindo eh a logica! Vlw!

#2 Prog

Prog

    ...

  • Ex-Admins
  • 3761 posts
  • Sexo:Masculino
  • Localidade:Rio de Janeiro/RJ
  • Interesses:TI, Software Livre, Design Digital e Rock'n'Roll.

Posted 25/06/2004, 17:47

Seu código funciona, o problema esta na hora de exibir a informação.

altere a linha:
showmessage(floattostr(maior));

para:
showmessage(fi[maior]);
------
Mero mortal!




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq