Esempio n. 1
0
 public matran tong(matran t2)
 {
     if (this.m == t2.m && this.n == t2.n)
     {
         matran t = new matran();
         t.m = this.m;
         t.n = this.n;
         t.a = new int[this.m, this.n];
         for (int i = 0; i < t.m; ++i)
         {
             for (int j = 0; j < t.m; ++i)
             {
                 t.a[i, j] = this.a[i, j] + t2.a[i, j];
             }
         }
         return(t);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 2
0
            static void Main1()
            {
                Console.WriteLine("Nhap thong tin cho ma tran thu nhat");
                matran t1 = new matran();

                t1.Nhap();
                Console.WriteLine("nhap thong tin ma tran thu nhat");
                matran t2 = new matran();

                t2.Nhap();
                matran t3 = t1.tong(t2);

                if (t3 == null)
                {
                    Console.WriteLine("Hai ma tran co kich thuoc khac nhau,ko tinh duoc tong");
                }
                else
                {
                    Console.WriteLine("thong tin cua ma tran tong");
                    t3.Hien();
                }
                Console.ReadKey();
            }