Пример #1
0
 public Vector(Vector vector)
 {
     coords = new int[vector.coords.Length];
     for (int i = 0; i < vector.coords.Length; i++)
     {
         coords[i] = vector.coords[i];
     }
 }
Пример #2
0
 public static Vector operator+(Vector one, Vector two)
 {
     if (one.coords.Length!=two.coords.Length)
     {
         throw new Exception("Lenght of the two vectors is diffrent");
     }
     Vector sum = new Vector(one);
     for (int i = 0; i <one.coords.Length; i++)
     {
         sum[i] = one.coords[i] + two.coords[i];
     }
     return sum;
 }
Пример #3
0
 public static Vector operator-(Vector one, Vector two)
 {
     if (one.coords.Length != two.coords.Length)
     {
         throw new Exception("Lenght of the two vectors is diffrent");
     }
     Vector diff = new Vector(one);
     for (int i = 0; i < diff.coords.Length; i++)
     {
         diff[i] = one.coords[i] - two.coords[i];
     }
     return diff;
 }
Пример #4
0
 static void Main(string[] args)
 {
     Vector one = new Vector(new int[] { 1, 2, 2, 2 });
     Vector two = new Vector(new int[] { 1 ,2, 2, 1 });
     Console.WriteLine(one*two);
 }