示例#1
0
        static void Main(string[] args)
        {
            try
            {
                Console.Write("Input TwoDimArray size ");
                int size = Convert.ToInt32(Console.ReadLine());

                TwoDimArray array  = new TwoDimArray(size);
                TwoDimArray array1 = array;
                array.Input();
                Console.WriteLine();
                array.Output();
                Console.Write("Columns sum: ");
                array.ColumnSum();
                Console.WriteLine();
                Console.WriteLine("The amount of zero is " + array.CountZero);

                Console.Write("Input scalar ");
                int scal = Convert.ToInt32(Console.ReadLine());
                array.ScalMainDiag = scal;
                array.Output();
                Console.WriteLine();
                Console.WriteLine("Getting element at [0;0] " + array[0, 0]);
                Console.WriteLine();
                Console.WriteLine("Increasing all by 1");
                array++;
                array.Output();
                Console.WriteLine();
                Console.WriteLine("Decreasing all by 1");
                array--;
                array.Output();
                Console.WriteLine();
                Console.WriteLine("Addition of two same arrays:");
                Console.WriteLine("First array:");
                array.Output();
                Console.WriteLine();
                Console.WriteLine("Second array:");
                array.Output();
                Console.WriteLine();
                Console.WriteLine("Result:");
                array = array + array;
                array.Output();
            }
            catch (FormatException)
            {
                Console.WriteLine("Incorrect format");
            }
            catch
            {
                Console.WriteLine("Unknow mistake");
            }
            Console.ReadKey();
        }
示例#2
0
        public static TwoDimArray operator ++(TwoDimArray array)
        {
            TwoDimArray obj = new TwoDimArray(array.IntArray.GetLength(0));

            for (int i = 0; i < array.IntArray.GetLength(0); i++)
            {
                for (int k = 0; k < array.IntArray.GetLength(1); k++)
                {
                    obj.IntArray[i, k] = array.IntArray[i, k] + 1;
                }
            }
            return(obj);
        }