Exemplo n.º 1
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); }
 }
Exemplo n.º 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); }
        }
Exemplo n.º 3
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); }
 }
Exemplo n.º 4
0
        public Menu()
        {
            Coleccion = new ArrayList();
            Matrices matrizResultado = new Matrices(1, 1);

            matrizResultado.setNombre("R");
            Coleccion.Add(matrizResultado);
        }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
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); }
 }
Exemplo n.º 8
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();
 }