Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Nhập thông tin cho ma trận thứ nhất:");
            matran t1 = new matran(2, 3);

            t1.nhap();
            Console.WriteLine("Nhập thông tin cho ma trận thứ 2:");
            matran t2 = new matran(t1);
            matran t3 = t1.Tong(t2);

            if (t3 == null)
            {
                Console.WriteLine("Hai ma trận không cùng số hàng số cột không tính được tổng!");
            }
            else
            {
                Console.WriteLine("Thông tin của ma trận tổng :");
                t3.print();
            }
            matran t4 = t1.Hieu(t2);

            if (t4 == null)
            {
                Console.WriteLine("không tính được!");
            }
            t4.print();
            Console.ReadKey();
        }
Esempio n. 2
0
        public matran(matran t2)

        {
            this.sh = t2.sc;
            this.sc = t2.sh;
            this.A  = new int[sh, sc];
            for (int i = 0; i < sh; i++)
            {
                for (int j = 0; j < sc; i++)
                {
                    this.A[i, j] = t2.A[i, j];
                }
            }
        }
Esempio n. 3
0
 public matran Hieu(matran t2)
 {
     if (this.sh == t2.sh && this.sc == t2.sc)
     {
         matran t = new matran(this.sh, this.sc);
         for (int i = 0; i < t.sh; i++)
         {
             for (int j = 0; j < t.sc; j++)
             {
                 t.A[i, j] = this.A[i, j] - t2.A[i, j];
             }
         }
         return(t);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 4
0
 public matran Tong(matran t2)
 {
     // TÍNH TỔNG
     if (this.sh == t2.sh && this.sc == t2.sc)
     {
         matran t = new matran(this.sh, this.sc);
         for (int i = 0; i < t.sh; i++)
         {
             for (int j = 0; j < t.sc; j++)
             {
                 t.A[i, j] = this.A[i, j] + t2.A[i, j];
             }
         }
         return(t);
     }
     else
     {
         return(null);
     }
 }