Exemple #1
0
        public static newArray operator +(newArray aFirstArr, newArray aSecondArr)
        {
            try
            {
                CheckSizes(aFirstArr, aSecondArr);

                newArray temp = new newArray(aFirstArr.rows, aFirstArr.columns);

                for (int i = 0; i < aFirstArr.rows; i++)
                {
                    for (int j = 0; j < aFirstArr.columns; j++)
                    {
                        temp.arr[i, j] = aFirstArr.arr[i, j] + aSecondArr.arr[i, j];
                    }
                }
                return temp;
            }

            catch (sizeExeption exn)
            {
                Console.WriteLine(exn.Message);
                Console.WriteLine("будет сгенерирована нулевая матрица");
                return new newArray(aFirstArr.rows, aSecondArr.columns);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            newArray arr1 = new newArray(3, 3);

            newArray arr2 = new newArray(3);

            arr1.FillArray(-1, 5);
            arr2.FillArray(-1, 5);

            arr1.Show();
            Console.WriteLine();
            arr2.Show();
            Console.WriteLine();

            newArray solution = arr1 + arr2;
            solution.Show();
            Console.WriteLine();
            solution = arr1 - arr2;
            solution.Show();
            Console.WriteLine();
            solution = arr1 * arr2;
            solution.Show();
        }
Exemple #3
0
 static int Continue_Multiply(int aI, int aJ, newArray aFirstArr, newArray aSecondArr)
 {
     int result = 0;
     for (int i = 0; i < aFirstArr.rows; i++)
     {
         result += aFirstArr.arr[aI, i] * aSecondArr.arr[i, aJ];
     }
     return result;
 }
Exemple #4
0
 static void CheckSizes(newArray aFirstArr, newArray aSecondArr)
 {
     try
     {
         if ((aFirstArr.rows != aSecondArr.rows) | (aFirstArr.columns != aSecondArr.columns))
         {
             throw new sizeExeption("массивы не одинаковы по размерам");
         }
     }
     catch (sizeExeption)
     {
         throw;
     }
 }