miércoles, 11 de diciembre de 2013

NUMERO MAYOR DE LA MATRIZ

NUMERO MAYOR DE UNA MATRIZ DE 3 X 3


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace MAYORDEUNAMATRIZ

{

    class Program

    {

        static void Main(string[] args)

        {

            int[,] a, b, c;

            int x, y, w, z, e, f,MAYOR;

            string aux;

            a = new int[3, 3];

            b = new int[3, 3];

            c = new int[3, 3];

            x = 5;

            for (e = 0; e < 3; e++)

            {

                f = 0; y = 5;

                while (f < 3)

                {

                    Console.SetCursorPosition(y, x);

                    aux = Console.ReadLine();

                    a[f, e] = int.Parse(aux);

                    f++;

                    y = y + 10;

                }

                x = x + 5;

            }

 

// OJO, AQUÍ SE OBTIENE EL NUMERO MAYOR DE LA MATRIZ

 

            MAYOR = 0;

            for (e = 0; e < 3; e++)

            {

                f = 0; y = 5;

                while (f < 3)

                {

                    if (MAYOR < a[f, e])

                    {

                        MAYOR = a[f, e];

                    }

                    f++;

                }

                x = x + 5;

            }

            Console.SetCursorPosition(50, 5);

            Console.Write(MAYOR);

            Console.ReadKey();

        }

    }

}

domingo, 8 de diciembre de 2013

MULTIPLICACION DE MATRICES DE 3 X 3

LLENAR 2 MATRICES DESDE TECLADO, MULTIPLICARLAS Y EL RESULTADO GUARDARLO EN UNA TERCER MATRIZ.


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication15

{

    class Program

    {

        static void Main(string[] args)

        {

            int[,] a, b, c;

            int x, y,w, z, e, f;

            string aux;

            a = new int[3, 3];

            b = new int[3, 3];

            c = new int[3, 3];

            x = 5;

            for (e = 0; e < 3; e++)

            {

                f = 0; y = 5;

                while (f < 3)

                {

                    Console.SetCursorPosition(y,x);

                    aux = Console.ReadLine();

                    a[f,e] = int.Parse(aux);

                    f++;

                    y = y + 10;

                }

                x = x + 5;

            }

            x = 5;

            for (e = 0; e < 3; e++)

            {

                f = 0; y = 45;

                while (f < 3)

                {

                    Console.SetCursorPosition(y, x);

                    aux = Console.ReadLine();

                    b[f, e] = int.Parse(aux);

                    f++;

                    y = y + 10;

                }

                x = x + 5;

            }

            //MULTIPLICACION DE LAS 2 MATRICES ANTERIORES

            x = 30;
            for (z = 0; z < 3; z++)
            {         
                y = 0; f = 25;
                while (y < 3)
                {
                     w = 0;
                    for (e = 0; e < 3; e++)
                    {
                        w = w + a[e, z] * b[y, e];
                    }
                    c[y, z] = w;
                    Console.SetCursorPosition(f,x);
                    Console.WriteLine(c[y,z]);
                                        y++;

                    f = f + 10;

                }

                x = x + 5;

            }

            Console.ReadKey();

        }

    }

}