Advertisement
Legiomax

C#_3_work_by_specific_column_and_field

Jan 18th, 2024
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | Software | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace C_Ijun
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int[,] twoSizeArray = new int[4, 4];
  15.             int rowSum = 0;
  16.             int colMult = 1;
  17.             int lowRangeRandom = 0;
  18.             int highRangeRandom = 10;
  19.             int arrayIndBySum = 2;
  20.             int arrayIndByMulti = 1;
  21.  
  22.             Random random = new Random();
  23.  
  24.             for (int i = 0; i < twoSizeArray.GetLength(0); i++)
  25.             {
  26.                 for (int j = 0; j < twoSizeArray.GetLength(1); j++)
  27.                 {
  28.                     twoSizeArray[i, j] = random.Next(lowRangeRandom, highRangeRandom);
  29.                 }
  30.             }
  31.  
  32.             for (int i = 0; i < twoSizeArray.GetLength(0); i++)
  33.             {
  34.                 for (int j = 0; j < twoSizeArray.GetLength(1); j++)
  35.                 {
  36.                     Console.Write(twoSizeArray[i, j] + " ");
  37.                 }
  38.  
  39.                 Console.WriteLine();
  40.             }
  41.  
  42.             for (int j = 0; j < twoSizeArray.GetLength(1); j++)
  43.             {
  44.                 rowSum += twoSizeArray[arrayIndBySum - 1, j];
  45.             }
  46.  
  47.             for (int i = 0; i < twoSizeArray.GetLength(0); i++)
  48.             {
  49.                 colMult *= twoSizeArray[i, arrayIndByMulti - 1];
  50.             }
  51.  
  52.             Console.WriteLine($"Сумма чисел строки {arrayIndBySum} - {rowSum}");
  53.             Console.WriteLine($"Произведение чисел столбца {arrayIndByMulti} - {colMult}");
  54.             Console.ReadKey();
  55.         }
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement