Advertisement
Stray_Wolf

ArrayCalculations

Apr 5th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ArrayHomework
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int summ = 0;            
  14.             int multiplication = 1;
  15.             int[,] array = { { 8, 3, 4, 12 },
  16.                              { 6, 3, 2, 11 },
  17.                              { 2, 8, 9, 15 }
  18.             };
  19.             Console.WriteLine("Массив:");
  20.             for (int i = 0; i < array.GetLength(0); i++)
  21.             {
  22.                 for (int j = 0; j < array.GetLength(1); j++)
  23.                 {
  24.                     Console.Write(array[i, j] + "|");
  25.                 }
  26.             }
  27.             for (int i = 0; i < array.GetLength(1); i++)
  28.             {
  29.                 summ += array[1, i];
  30.             }
  31.             for (int i = 0; i < array.GetLength(0); i++)
  32.             {
  33.                 multiplication *= array[i, 0];
  34.             }
  35.  
  36.             Console.WriteLine("\n\nСумма второй строки:" + summ + "\nПроизведение первого столбца: " + multiplication);        
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement