Example #1
0
 public Vecto Hieu(Vecto t2)
 {
     if (this.n == t2.n)
     {
         Vecto t = new Vecto(this.n);
         for (int i = 0; i < n; i++)
         {
             t.v[i] = this.v[i] - t2.v[i];
         }
         return(t);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        static void Main5_3(string[] args)
        {
            Console.WriteLine("Nhap thong tin cho vecto thu nhat");
            Vecto t1 = new Vecto(); t1.Nhap();

            Console.WriteLine("Nhap thong tin cho vecto thu hai");
            Vecto t2 = new Vecto(); t2.Nhap();

            Console.WriteLine("Tong hai vecto");
            Vecto tong = t1.Tong(t2);

            if (tong == null)
            {
                Console.WriteLine("Khong tinh tong duoc vi 2 vecto co kich thuoc khong bang nhau");
            }
            else
            {
                Console.WriteLine("Tong 2 vecto");
                tong.Hien();
            }

            Console.WriteLine("Hieu hai vecto");
            Vecto hieu = t1.Hieu(t2);

            if (hieu == null)
            {
                Console.WriteLine("Khong tinh hieu duoc vi 2 vecto co kich thuoc khong bang nhau");
            }
            else
            {
                Console.WriteLine("Hieu 2 vecto");
                hieu.Hien();
            }



            Console.ReadKey();
        }