using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] A = new int[2, 2];
            int[,] B = new int[2, 2];
            int[,] Result = new int[2, 2];

            //미리 입력 해 놓고 계산 하실거면 이걸 쓰세요.
            //그리고 입력 부분 for문은 삭제 하시구요.
            //int[,] A =
            //    {
            //        {3, 2},
            //        {1, 4}
            //    };
            //int[,] B =
            //    {
            //        {9, 2},
            //        {1, 7}
            //    };

            //입력 부분입니다.
            //행렬을 A, B로 정하셔서 배열을 두개 생성 했습니다.
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Console.Write("{0},{1}부분 입력: ", i, j);
                    A[i, j] = Int32.Parse(Console.ReadLine());
                }//end of for2
            }//end of for1
            Console.WriteLine();
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Console.Write("{0},{1}부분 입력: ", i, j);
                    B[i, j] = Int32.Parse(Console.ReadLine());
                }//end of for2
            }//end of for1

            Console.WriteLine();

            //계산 하는 부분입니다.(A*B)
            for (int i = 0; i < 2; i++)
            {
                Result[i, 0] = A[i, 0] * B[0, 0] + A[i, 1] * B[i, 0];
                Result[i, 1] = A[i, 0] * B[0, 1] + A[i, 1] * B[1, 1];
            }//end of for1

            //결과값 출력 부분입니다.
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Console.Write("{0} ", Result[i, j]);
                    if (j == 1) Console.WriteLine();
                }//end of for2
            }//end of for1
        }//end of Main
    }//end of Program_Class
}//end of namespeace

+ Recent posts