예제 #1
0
 public void MenuAJI(Matrices matrizInversa)
 {
     try
     {
         Console.Clear();
         this.NombreMenu("Multiplicar un renglon por C y sumarlo a otro");
         int renglon1, renglon2, c;
         do
         {
             this.Instrucciones("Indique el numero del primer renglon  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
             renglon1 = Convert.ToInt32(Console.ReadLine());
         } while (renglon1 >= matrizInversa.getRenglon());
         do
         {
             this.Instrucciones("Indique el numero del segundo renglon  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
             renglon2 = Convert.ToInt32(Console.ReadLine());
         } while (renglon2 >= matrizInversa.getRenglon());
         this.Instrucciones("Indique la constante: ");
         c = Convert.ToInt32(Console.ReadLine());
         matrizInversa.setNombre("Multiplicacion del renglon: " + renglon1 + ", multiplicado  por: " + c + " y sumado a renglon: " + renglon2);
         for (int j = 0; j < matrizInversa.getColumna(); j++)
         {
             matrizInversa.setElemento(renglon2, j, (matrizInversa.getElemento(renglon1, j) * c) + matrizInversa.getElemento(renglon2, j));
         }
     }
     catch (Exception)
     { this.MenuAJI(matrizInversa); }
 }
예제 #2
0
        public void MenuAZI(Matrices matrizInversa)
        {
            try
            {
                this.NombreMenu("Intercambiar un renglon por otro");
                Console.Clear();
                int      renglon1, renglon2;
                Matrices memoria = new Matrices(matrizInversa.getColumna());
                do
                {
                    this.Instrucciones("Indique el numero del primer renglon  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
                    renglon1 = Convert.ToInt32(Console.ReadLine());
                } while (renglon1 >= matrizInversa.getRenglon());
                do
                {
                    this.Instrucciones("Indique el numero del segundo renglon  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
                    renglon2 = Convert.ToInt32(Console.ReadLine());
                } while (renglon2 >= matrizInversa.getRenglon());
                matrizInversa.setNombre("intercambio de renglones " + renglon1 + " y " + renglon2);
                for (int i = 0; i < matrizInversa.getColumna(); i++)
                {
                    memoria.setElemento(i, matrizInversa.getElemento(renglon1, i));
                    matrizInversa.setElemento(renglon1, i, matrizInversa.getElemento(renglon2, i));
                    matrizInversa.setElemento(renglon2, i, memoria.getElemento(i));
                }

                /*
                 *  memoria[i] = otro[i];
                 *  otro[i] = matriz[i];
                 *  matriz[i] = memoria[i];
                 */
            }
            catch (Exception)
            { this.MenuAZI(matrizInversa); }
        }
예제 #3
0
 public void MenuANI(Matrices matrizInversa)
 {
     try
     {
         this.NombreMenu("Multiplicar por 1/C");
         int    renglon;
         double cc, tmp1, tmp2, tmp3, c;
         Console.Clear();
         do
         {
             Console.Write("Indique el numero del renglon a multiplicar  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
             renglon = Convert.ToInt32(Console.ReadLine());
         } while (renglon >= matrizInversa.getRenglon());
         this.Instrucciones("Indique la constante: ");
         c  = Convert.ToDouble(Console.ReadLine());
         cc = 1 / c;
         matrizInversa.setNombre("Multiplicacion del renglon: " + renglon + ", multiplicado  por la inversa de : " + c);
         for (int i = 0; i < matrizInversa.getColumna(); i++)
         {
             tmp1 = (matrizInversa.getElemento(renglon, i) * cc) * 100;
             tmp2 = Math.Truncate(tmp1);
             tmp3 = tmp2 / 100;
             matrizInversa.setElemento(renglon, i, tmp3);
         }
     }
     catch (Exception)
     { this.MenuANI(matrizInversa); }
 }
예제 #4
0
        public Menu()
        {
            Coleccion = new ArrayList();
            Matrices matrizResultado = new Matrices(1, 1);

            matrizResultado.setNombre("R");
            Coleccion.Add(matrizResultado);
        }
예제 #5
0
 public void MenuVT()
 {
     Console.Clear();
     this.NombreMenu("Todas");
     for (int i = 0; i < Coleccion.Count; i++)
     {
         Matrices tmpMatriz = (Matrices)Coleccion[i];
         tmpMatriz.verContenido();
     }
     this.espera();
     this.MenuV();
 }
예제 #6
0
        //metodos
        public int encontrarMatriz(string nombre)
        {
            int resultado = 1;

            for (int i = 0; i < Coleccion.Count; i++)
            {
                Matrices tmpMatriz = (Matrices)Coleccion[i];
                string   dato      = tmpMatriz.getNombre();
                if (nombre.Equals(dato))
                {
                    resultado = i;
                }
            }
            return(resultado);
        }
예제 #7
0
 public Matrices resta(Matrices matrizA, Matrices matrizB)
 {
     Matrices resultado;
     resultado = new Matrices(matrizA.getRenglon(), matrizA.getColumna());
     resultado.setNombre("Resta de " + matrizA.getNombre() + " - " + matrizB.getNombre());
     for (int i = 0; i < matrizA.getRenglon(); i++)
     {
         for (int j = 0; j < matrizA.getColumna(); j++)
         {
             resultado.setElemento(i, j, matrizA.getElemento(i, j) - matrizB.getElemento(i, j));
         }//i
         Console.WriteLine("");
     }//j
     return resultado;
 }
예제 #8
0
 public Matrices matrizAumentada(Matrices seleccionada)
 {
     Matrices resultado = new MatrizCalculadora.Matrices(seleccionada.getRenglon(), seleccionada.getColumna() + seleccionada.getColumna());
     resultado.setNombre("Aumentada");
     for (int i = 0; i < seleccionada.getRenglon(); i++)
     {
         for (int j = 0; j < seleccionada.getColumna(); j++)
         {
             resultado.setElemento(i, j, seleccionada.getElemento(i, j));
         }//i
     }//j
     for (int t = 0; t < seleccionada.getColumna(); t++)
     {
         resultado.setElemento(t, seleccionada.getColumna() + t, 1);
     }//i
     return resultado;
 }
예제 #9
0
        public void MenuOA()
        {
            Matrices    matrizSeleccionada = new Matrices();
            Matrices    matrizTemporal = new Matrices();
            Matrices    matrizInversa = new Matrices();
            Operaciones miOperacion = new Operaciones();
            string      nombre; int posicion;
            bool        paseBool = true;

            Console.Clear();
            this.NombreMenu("Asistente para inversa");
            this.Instrucciones("Ingrese el nombre de la matriz : ");
            nombre             = Console.ReadLine();
            posicion           = this.encontrarMatriz(nombre);
            matrizSeleccionada = (Matrices)Coleccion[posicion];
            matrizSeleccionada.verContenido();
            matrizInversa = miOperacion.matrizAumentada(matrizSeleccionada);
            matrizInversa.verContenido();
            while (paseBool)
            {
                Console.Clear();
                this.NombreMenu("Asistente para inversa");
                Console.WriteLine();
                matrizTemporal = matrizInversa;
                matrizTemporal.verContenido();
                char tmpChar;
                Console.WriteLine();
                this.Visualizacion("m)Multiplicar un renglon por C", "n)Multiplicar un renglon por 1/C", "j)Multiplicar un renglon por C y sumarlo a otro", "z)Intercambiar un renglon por otro", "x)salir");
                tmpChar = Console.ReadKey(true).KeyChar;
                switch (tmpChar)
                {
                case 'j': this.MenuAJI(matrizInversa); break;

                case 'm': this.MenuAMI(matrizInversa); break;

                case 'n': this.MenuANI(matrizInversa); break;

                case 'z': this.MenuAZI(matrizInversa); break;

                case 'x': paseBool = false; break;
                }
            }
            this.MenuO();
        }
예제 #10
0
        public void MenuOM()
        {
            try
            {
                Console.Clear();
                this.NombreMenu("Multiplicacion");
                Matrices    primeraMatriz = new Matrices();
                Matrices    segundaMatriz = new Matrices();
                Matrices    resultadoMatriz = new Matrices();
                Operaciones miOperacion = new Operaciones();
                string      nombre1, nombre2;
                Console.Clear();

                this.Instrucciones("Ingrese el nombre de la matriz 1: ");
                nombre1 = Console.ReadLine();
                for (int i = 0; i < Coleccion.Count; i++)
                {
                    Matrices tmpMatriz = (Matrices)Coleccion[i];
                    if (tmpMatriz.getNombre() == nombre1)
                    {
                        this.setPosicion1(i);
                    }
                }
                this.Instrucciones("Ingrese el nombre de la matriz 2: ");
                nombre2 = Console.ReadLine();
                for (int j = 0; j < Coleccion.Count; j++)
                {
                    Matrices tmpMatriz = (Matrices)Coleccion[j];
                    if (tmpMatriz.getNombre() == nombre2)
                    {
                        this.setPosicion2(j);
                    }
                }
                primeraMatriz = (Matrices)Coleccion[this.getPosicion1()];
                segundaMatriz = (Matrices)Coleccion[this.getPosicion2()];
                //se realiza la operacion
                resultadoMatriz = miOperacion.multiplicacion(primeraMatriz, segundaMatriz);
                Coleccion[0]    = resultadoMatriz;
            }
            catch (Exception)
            { this.MenuOM(); }
            this.MenuO();
        }
예제 #11
0
        public void MenuVI()
        {
            string nombre;

            Console.Clear();
            this.NombreMenu("Individual");
            Console.WriteLine("NOTA: El nombre debe ser como lo guardo, de lo contrario no va a aparecer");
            this.Instrucciones("Ingrese el nombre de la matriz a buscar: ");
            nombre = Console.ReadLine();
            for (int i = 0; i < Coleccion.Count; i++)
            {
                Matrices tmpMatriz = (Matrices)Coleccion[i];
                if (tmpMatriz.getNombre() == nombre)
                {
                    Console.Clear(); tmpMatriz.verContenido();
                }
            }
            this.espera();
            this.MenuV();
        }
예제 #12
0
 public Matrices multiplicacion(Matrices matrizA, Matrices matrizB)
 {
     Matrices resultado;
     resultado = new Matrices(matrizA.getRenglon(), matrizB.getColumna());
     resultado.setNombre("Multiplicacion  de " + matrizA.getNombre() + " * " + matrizB.getNombre());
     int tope = matrizA.getColumna();
     double tmp = 0;
     for (int i = 0; i < tope; i++)
     {
         for (int j = 0; j < tope; j++)
         {
             tmp = 0;
             for (int k = 0; k < tope; k++)
             {
                 tmp = tmp + (matrizA.getElemento(k, i) * matrizB.getElemento(j, k));
             }
             resultado.setElemento(j, i, tmp);
         }
     }
     return resultado;
 }
예제 #13
0
 public void MenuAMI(Matrices matrizInversa)
 {
     try
     {
         this.NombreMenu("Multiplicar un renglon por C");
         int renglon, c;
         Console.Clear();
         do
         {
             this.Instrucciones("Indique el numero del renglon a multiplicar  (limite 0-" + (matrizInversa.getRenglon() - 1) + "): ");
             renglon = Convert.ToInt32(Console.ReadLine());
         } while (renglon >= matrizInversa.getRenglon());
         this.Instrucciones("Indique la constante: ");
         c = Convert.ToInt32(Console.ReadLine());
         matrizInversa.setNombre("Multiplicacion del renglon: " + renglon + ", multiplicado  por: " + c);
         for (int i = 0; i < matrizInversa.getColumna(); i++)
         {
             matrizInversa.setElemento(renglon, i, matrizInversa.getElemento(renglon, i) * c);
         }
     }
     catch (Exception)
     { this.MenuAMI(matrizInversa); }
 }
예제 #14
0
 public void MenuCP()
 {
     try
     {
         Matrices nuevaMatrizPrpia;
         string   tmpNombre;
         int      renglones, columnas;
         bool     automatica = false;
         Console.Clear();
         this.NombreMenu("Propia");
         this.Instrucciones("Nombre de la matriz: ");
         tmpNombre = Console.ReadLine();
         this.Instrucciones("Numero de renglones: ");
         renglones = Convert.ToInt32(Console.ReadLine());
         this.Instrucciones("Numero de columnas: ");
         columnas         = Convert.ToInt32(Console.ReadLine());
         nuevaMatrizPrpia = new Matrices(renglones, columnas, automatica);
         nuevaMatrizPrpia.setNombre(tmpNombre);
         Coleccion.Add(nuevaMatrizPrpia);
     }
     catch (Exception)
     { this.MenuCP(); }
     this.MenuC();
 }