Principal
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

arreglo de 5 notas

Ir abajo

arreglo de 5 notas Empty arreglo de 5 notas

Mensaje  Israfel Dom Feb 13, 2011 7:09 pm

programa que dada 5 notas este identifique las notas repetidas..
{Si saben como mejorar este programa se les agradeceria comentarlo}


program numeros;
uses crt;
var
x,a,y,b,c,d,e,f:integer;
no:array[1..5]of integer;
begin
clrscr;
x:=0; a:=0;b:=0; c:=0; d:=0; e:=0; f:=0;
repeat
f:=f+1;
x:=x+1;
writeln('Diga la nota ',f);
readln(no[x]);
until
(x=5);
if(no[1]=no[1])then
a:=a+1;
if(no[1]=no[2])then
a:=a+1;
if(no[1]=no[3])then
a:=a+1;
if(no[1]=no[4])then
a:=a+1;
if(no[1]=no[5])then
a:=a+1;
if(no[2]=no[1])then
b:=b+1;
if(no[2]=no[2])then
b:=b+1;
if(no[2]=no[3])then
b:=b+1;
if(no[2]=no[4])then
b:=b+1;
if(no[2]=no[5])then
b:=b+1;
if(no[3]=no[1])then
c:=c+1;
if(no[3]=no[2])then
c:=c+1;
if(no[3]=no[3])then
c:=c+1;
if(no[3]=no[4])then
c:=c+1;
if(no[3]=no[5])then
c:=c+1;
if(no[4]=no[1])then
d:=d+1;
if(no[4]=no[2])then
d:=d+1;
if(no[4]=no[3])then
d:=d+1;
if(no[4]=no[4])then
d:=d+1;
if(no[4]=no[5])then
d:=d+1;
if(no[5]=no[1])then
e:=e+1;
if(no[5]=no[2])then
e:=e+1;
if(no[5]=no[3])then
e:=e+1;
if(no[5]=no[4])then
e:=e+1;
if(no[5]=no[5])then
e:=e+1;
if(a>1)then
Writeln('La primera nota esta repetida ',a,' veces');
if(b>1)then
Writeln('La segunda nota esta repetida ',b,' veces');
if(c>1)then
Writeln('La tercera nota esta repetida ',c,' veces');
if(d>1)then
Writeln('La cuarta nota esta repetida ',d,' veces');
if(e>1)then
Writeln('La quinta nota esta repetida ',e,' veces');
if(a=1)AND(b=1)and(c=1)and(d=1)and(c=1)then
Write('ninguna nota esta repetida');
readkey;
end.
Israfel
Israfel

Mensajes : 28
Fecha de inscripción : 12/02/2011
Edad : 34

Volver arriba Ir abajo

Volver arriba


 
Permisos de este foro:
No puedes responder a temas en este foro.