コード例 #1
0
 public Massiv(Massiv m)
 {
     this.Length = m.Length;
     for (int i = 0; i < m.Length; i++)
     {
         this.Arra[i] = m.Arra[i];
     }
 }
コード例 #2
0
        public void Sum(Massiv mas)
        {
            int summ = 0;

            for (int i = 0; i < mas.Length; i++)
            {
                summ += mas.Arra[i];
            }
            Console.WriteLine($"Sum of elements is {summ}");
        }
コード例 #3
0
        public static Massiv operator +(Massiv m1, Massiv m2)
        {
            Massiv m3 = new Massiv {
                Length = m1.Length + m2.Length
            };

            m1.Arra.CopyTo(m3.arr, 0);
            m2.Arra.CopyTo(m3.arr, m1.Length);
            return(m3);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Massiv mas1 = new Massiv(11);

            for (int i = 0; i < mas1.Length; i++)
            {
                Console.WriteLine($"{mas1.Arra[i]}");
            }
            Console.WriteLine("---------");
            int[]  inpmas = new int[3];
            Massiv mas2   = new Massiv(3, inpmas);

            for (int i = 0; i < mas2.Length; i++)
            {
                Console.WriteLine($"{mas2.Arra[i]}");
            }
            Console.WriteLine("---");
            Massiv mas3 = mas2;

            for (int i = 0; i < mas3.Length; i++)
            {
                Console.WriteLine($"{mas3.Arra[i]}");
            }
            Console.WriteLine("--------");
            //Console.WriteLine(mas3.Length);
            //bool result = mas1 < mas2;
            //Console.WriteLine(result);
            //bool result1 = mas1 >= mas2;
            //Console.WriteLine(result1);
            //Console.WriteLine(mas1 + mas2);

            //mas1 = mas1 * 5;
            //for (int i = 0; i < mas1.Length; i++)
            //{
            //    Console.WriteLine(mas1.Arra[i]);
            //}
            StringBuilder sb  = new StringBuilder(mas1.Length);
            int           len = mas1.Length;

            int[] array = new int[len];
            for (int i = 0; i < len; i++)
            {
                array[i] = mas1.Arra[i];
                Console.WriteLine(array[i]);
                Console.WriteLine("---");
            }
            for (int i = 0; i < mas1.Length; i++)
            {
                sb.Append(array[i]);
            }
            string value = sb.ToString();

            Console.WriteLine(value);
            Console.WriteLine("-----");
            int rec = mas1.RecSum(0);

            Console.WriteLine(rec);
            string val = (string)mas1;

            Console.WriteLine(val);
        }