
Como calcularla media y mediana de 4 notas
Publicado por gerson (4 intervenciones) el 03/11/2014 20:46:58
calcular la moda la media y mediana de 4 notas ingresadas por el usuario porfa
Valora esta pregunta


0
Uses CRT;
Const
MAX = 4;
Type
TipoNotas = Array [1..4] of integer;
var
notas : tiponotas;
contador : integer;
aux : tiponotas;
posicion : integer;
numero:integer;
contador2:integer;
mayor : integer;
posicionmayor : Integer;
suma : integer;
media : real;
mediana : real;
i,j:integer;
begin
for contador:=1 to max do
begin
Writeln('Introduzca la nota ',contador);
readln(notas[contador]);
end;
For contador:=1 to max do
aux[contador]:=0;
For contador:=1 to max do
begin
numero:= notas[contador];
posicion:=contador;
for contador2:=contador to max do
if notas[contador2]=numero then
inc(aux[posicion]);
end;
mayor:=aux[1];
posicionmayor := 1;
for contador:=1 to max do
begin
if aux[contador]>mayor then
begin
posicionmayor:=contador;
mayor:=aux[contador]
end;
end;
{ordenamos el vector}
for i:= 1 to max do
for j:=1 to max do
begin
if notas[i]<notas[j] then
begin
numero:=notas[i];
notas[i]:=notas[j];
notas[j]:=numero;
end;
end;
Writeln('La moda es: ',notas[posicionmayor]);
for contador:=1 to max do
suma:=suma+notas[contador];
media:=suma / max;
mediana:=(notas[2]+notas[3]) / 2;
Writeln('La mediana es: ',mediana:2:2);
writeln('La media es: ',media:2:2);
readln;
end.