コード例 #1
0
        private static void DecimalArrayProcessing()
        {
            ArrayLength();
            decimal[] decimalArr = new decimal[length];
            for (int i = 0; i < decimalArr.Length; i++)
            {
                decimalArr[i] = Convert.ToDecimal(Math.Round(SingleRandom.Next(-100000, 100000) + SingleRandom.NextDouble(), 7));
            }

            ConsolePrintArray(decimalArr);
            decimal decimalSum = decimalArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {decimalSum.ToString()}");
        }
コード例 #2
0
        private static void ShortArrayProcessing()
        {
            ArrayLength();
            short[] shortArr = new short[length];
            for (int i = 0; i < shortArr.Length; i++)
            {
                shortArr[i] = Convert.ToInt16(SingleRandom.Next(-1000, 1001));
            }

            ConsolePrintArray(shortArr);
            short shortSum = shortArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {shortSum.ToString()}");
        }
コード例 #3
0
        private static void SbyteArrayProcessing()
        {
            ArrayLength();
            sbyte[] sbyteArr = new sbyte[length];
            for (int i = 0; i < sbyteArr.Length; i++)
            {
                sbyteArr[i] = Convert.ToSByte(SingleRandom.Next(-10, 11));
            }

            ConsolePrintArray(sbyteArr);
            sbyte sumSbyte = sbyteArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {sumSbyte.ToString()}");
        }
コード例 #4
0
        private static void UshortArrayProcessing()
        {
            ArrayLength();
            ushort[] ushortArr = new ushort[length];
            for (int i = 0; i < ushortArr.Length; i++)
            {
                ushortArr[i] = Convert.ToUInt16(SingleRandom.Next(0, 1001));
            }

            ConsolePrintArray(ushortArr);
            ushort ushortSum = ushortArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {ushortSum.ToString()}");
        }
コード例 #5
0
        private static void IntArrayProcessing()
        {
            ArrayLength();
            int[] intArr = new int[length];
            for (int i = 0; i < intArr.Length; i++)
            {
                intArr[i] = SingleRandom.Next(-1000000, 1000000);
            }

            ConsolePrintArray(intArr);
            int intSum = intArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {intSum.ToString()}");
        }
コード例 #6
0
        private static void LongArrayProcessing()
        {
            ArrayLength();
            long[] longArr = new long[length];
            for (int i = 0; i < longArr.Length; i++)
            {
                longArr[i] = Convert.ToInt64(SingleRandom.Next(-10000000, 10000000));
            }

            ConsolePrintArray(longArr);
            long longSum = longArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {longSum.ToString()}");
        }
コード例 #7
0
        private static void UlongArrayProcessing()
        {
            ArrayLength();
            ulong[] ulongArr = new ulong[length];
            for (int i = 0; i < ulongArr.Length; i++)
            {
                ulongArr[i] = Convert.ToUInt64(SingleRandom.Next(0, 10000000));
            }

            ConsolePrintArray(ulongArr);
            ulong ulongSum = ulongArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {ulongSum.ToString()}");
        }
コード例 #8
0
        private static void FloatArrayProcessing()
        {
            ArrayLength();
            float[] floatArr = new float[length];
            for (int i = 0; i < floatArr.Length; i++)
            {
                floatArr[i] = Convert.ToSingle(Math.Round(SingleRandom.Next(-1000, 1000) + SingleRandom.NextDouble(), 3));
            }

            ConsolePrintArray(floatArr);
            float floatSum = floatArr.ArraySum();

            Console.WriteLine($"Sum of elements in array: {floatSum.ToString()}");
        }