Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Ayuda Con Un Programa (https://www.clubdelphi.com/foros/showthread.php?t=72799)

darnnezt 12-03-2011 02:02:13

Ayuda Con Un Programa
 
ANTE TODO AMIGOS SALUDOS A TODOS, CREO EL SIGUIENTE HILO CON EL FIN DE ENCONTRE SOLUCION A LOS SIGUIENTES ERRORES Q SE PRESENTAN EN LA SIGUIENTE CODIFICACION.

Código Delphi [-]
procedure TForm1.BitBtn1Click(Sender: TObject);
var  i,sumi,pro7,prom,n,cpro,num,sumpro,sumint:Integer;
begin
//injicialixacion

i:=0; sumi:=0; pro7:=1; cpro:=0; sumpro:=0; sumint:=0;
//prcesamiento

n:=strtoint(inputbox('CANTIDAD DE VALORES ENTEROS','N=',''));
//repetitiva
while ido
begin
num:= strtoint(inputbox('INGRESE EL NUMERO','NUM=',''));
if odd(num) then
sumi:= sumi+NUM;

if (num mod 7=0) then
pro7:= pro7*num;
if (num >= 43 and NUm <= 119) or (NUM >= -40 and NUM <= 10)then
sumint:= sumint+num;

if not odd(NUM) and Num >=0 and NUM >10 then
cpro:= cpro+1;
sumpro:= sumpro+NUM;
prom:= sumpro/cpro;

i:=i+1;

 end;

 showmessage('SUMA DE LOS IMPARES' + inttostr(sumi));
 showmessage('PRODUCTO DE MULTIPLOS DE 7' + inttostr(pro7));
 showmessage('SUMA DE INTERVALOS' + inttostr(sumint));
 showmessage('PROMEDIO' + inttostr(prom));





la linea roja es la del error ( dice que los operadores no son compatibles en la operacion)
Saludos y espero su cordial ayuda :)

Delphius 12-03-2011 02:23:01

¿Que no es acaso así?

Código Delphi [-]
if (algo = otracosa) AND (algo2 > otracosa2) ... ()

¡Lo que tu intentas hacer va en contra de la sintaxis aceptada por Pascal!

Saludos,

darnnezt 12-03-2011 02:23:58

ah okay gracias intentare nuevamente

Delphius 12-03-2011 02:27:51

Y si se necesita de evaluaciones compuestas:

Código Delphi [-]
if ((Num > 45) AND (Num < 100)) OR NoPermitido
then ....

Se ve en el ejemplo, el uso de doble paréntesis. El más exterior encierra la evaluación total y la compara con una hipotética variable booleana denominada NoPermitido.

Espero que con esto haya quedado más claro.

Saludos,

darnnezt 12-03-2011 02:34:32

oke hermano lo hice con 2 selectivas y el error persiste

darnnezt 12-03-2011 02:41:05

Cita:

Empezado por Delphius (Mensaje 393309)
Y si se necesita de evaluaciones compuestas:

Código Delphi [-]if ((Num > 45) AND (Num < 100)) OR NoPermitido then ....


Se ve en el ejemplo, el uso de doble paréntesis. El más exterior encierra la evaluación total y la compara con una hipotética variable booleana denominada NoPermitido.

Espero que con esto haya quedado más claro.

Saludos,

SI amigo corregi eran parentesis y cree 2 selectivas quedo de esta manera

darnnezt 12-03-2011 02:42:29

Código Delphi [-]
procedure TForm1.BitBtn1Click(Sender: TObject);
var  i,sumi,pro7,n,cpro,num,sumpro,sumint:Integer;
prom: real;
begin
//injicialixacion

i:=0; sumi:=0; pro7:=1; cpro:=0; sumpro:=0; sumint:=0;
//prcesamiento

n:=strtoint(inputbox('CANTIDAD DE VALORES ENTEROS','N=',''));
//repetitiva
while ido
begin
num:= strtoint(inputbox('INGRESE EL NUMERO','NUM=',''));
if odd(num) then
sumi:= sumi+NUM;

if (num mod 7=0) then
pro7:= pro7*num;

if ((num > 43) and  (num < 119)) then
        sumint:= sumint+num;
if  ((NUM > -40) and (NUM < 10 )) then
   begin
sumint:= sumint+num;
        end;







if ((not odd(NUM)) and (Num >=0) and (NUM >10)) then
cpro:= cpro+1;
sumpro:= sumpro+NUM;
prom:= sumpro/cpro;

i:=i+1;

 end;

 showmessage('SUMA DE LOS IMPARES' + inttostr(sumi));
 showmessage('PRODUCTO DE MULTIPLOS DE 7' + inttostr(pro7));
 showmessage('SUMA DE INTERVALOS' + inttostr(sumint));
 showmessage('PROMEDIO' + floattostr(prom));



Quedo de la siguiente manera

Delphius 16-03-2011 05:06:47

A ver... ¿Te salen errores? De ser así sería bueno que nos indiques textualmente cuáles y en qué lineas.

Saludos,

Casimiro Notevi 16-03-2011 11:33:50

Amigo, darnnezt, recuerda leer nuestra guia de estilo, muchas gracias por tu colaboración.


La franja horaria es GMT +2. Ahora son las 00:01:01.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi