• Lunes 13 de Mayo de 2024, 09:50

Autor Tema:  ESTADISTICA,PROMEDIO,DESVIACION ESTANDAR  (Leído 6174 veces)

NICY

  • Miembro activo
  • **
  • Mensajes: 42
  • Nacionalidad: mx
    • Ver Perfil
ESTADISTICA,PROMEDIO,DESVIACION ESTANDAR
« en: Viernes 19 de Junio de 2009, 00:43 »
0
Código: C++
  1.  

 static void Main(string[] args)
        {
            entrada_salida e = new entrada_salida();
            menu m = new menu();
            estadistica est = new estadistica();
            double[] arreglo = new double[10];
            int op;
            e.captura(arreglo, "capture 10 numeros", 10, 5);

            Console.Clear();
            do{
                Console.Clear();
            m.menu1(out op,10,5,"1.mayor","2.menor","3.promedio","4.desviacion estandar","5.salir");
            Console.Clear();
               
                switch(op)
            {
                case 1] variable)
        {
            double may;
            int i;
            may = variable[0];
            for (i = 1; i < variable.Length; i++)
            {
                if (variable > may)
                    may = variable;
            }
            return may;
        }


        public double menor(double[] variable)
        {
            double men;
            int i;
            men = variable[0];
            for (i = 1; i < variable.Length; i++)
            {
                if (variable < men)
                    men = variable;
            }
            return men;

        }

        public double promedio(double[] variable)
        {
            double p = 0;
            int i;

            for (i = 1; i < variable.Length; i++)
            {
                p = p + variable;
            }
            p = p / variable.Length;
            return p;
        }


        public double desviacion(double[] variable)
        {
            double desv = 0;
            int i;

            for (i = 1; i < variable.Length; i++)
            {
                desv = desv + Math.Pow(variable - promedio(variable), 2);
            }
            desv = desv / variable.Length - 1;
            desv = Math.Sqrt(desv);
            return desv;
        }
    }
}
       ************************************
class menu
    {
        public void menu1(out int opc,int z,int y,params string [] menu)
        {
            int x;
            for (x = 0; x < menu.Length; x++)
            {
                Console.SetCursorPosition(z, y + x);
                Console.WriteLine(menu
  • );

            }
            opc = int.Parse(Console.ReadLine());
       
       
        }
    }
}
*********************************
 class entrada_salida
    {

        public void imprime(double a, string mensaje, int x, int y)
        {
            Console.SetCursorPosition(x, y);
            Console.WriteLine("{0}{1}", mensaje, a);
        }
        public void captura(out int variable, string mensaje, int x, int y)
        {
            Console.SetCursorPosition(x, y);
            Console.Write(mensaje);
            variable = int.Parse(Console.ReadLine());
        }
        public void captura(double[] variable, string mensaje, int x, int y)
        {
            Console.SetCursorPosition(x, y - 1);
            Console.WriteLine(mensaje);
            for (int i = 0; i < variable.Length; i++)
            {
                Console.SetCursorPosition(x, y + i);
                variable = double.Parse(Console.ReadLine());

            }
        }

        public void captura(string[] variable, string mensaje, int x, int y)
        {
            Console.SetCursorPosition(x, y);
            Console.WriteLine("{0}{1}", mensaje, variable);
        }
       
       

        public void imprime(int[] variable, string mensaje, int x, int y)
        {

            int i, j;
            // metodo burbuja
            for (i = 0; i < variable.Length - 1; i++)
            {
                for (j = i + 1; j < variable.Length; j++)
                {
                    if (variable > variable[j])
                    {
                        int aux = variable;
                        variable = variable[j];
                        variable[j] = aux;
                    }
                }
            }
            // imprime arreglo ordenado


            Console.SetCursorPosition(x, y - 1);
            Console.WriteLine(mensaje);
            for (i = 0; i < variable.Length; i++)
            {
                Console.SetCursorPosition(x, y + i);




            }
        }

    }
}





BYEEEEEE :wacko: