Advertisement
CrewLab

day 03_3

May 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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 Les3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[,] arr =
  14.             {
  15.                 {4, 5, 3 },
  16.                 {1, 8, 7 },
  17.                 {2, 4, 0 }
  18.             };
  19.             int sum;
  20.             int prod;
  21.  
  22.             sum = 0;
  23.             prod = 1;
  24.             Console.WriteLine("Исходная матрица:\n");
  25.             for (int i = 0; i < arr.GetLength(0); i++)
  26.             {
  27.                 for (int j = 0; j < arr.GetLength(1); j++)
  28.                 {
  29.                     Console.Write(arr[i, j]);
  30.                 }
  31.                 Console.WriteLine();
  32.             }
  33.             Console.WriteLine();
  34.             for (int i = 0; i < arr.GetLength(1); i++)
  35.                 sum += arr[1, i];
  36.             Console.WriteLine("Сумма второй строки: " + sum);
  37.             for (int i = 0; i < arr.GetLength(0); i++)
  38.                 prod *= arr[i, 0];
  39.             Console.WriteLine();
  40.             Console.WriteLine("Произведение первого столбца: " + prod);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement