Advertisement
Guest User

3.3

a guest
May 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 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.  
  14.             Console.Title = "3.3 Матрица";
  15.  
  16.             int[,] arrMatrix = {
  17.                                  { 1, 2, 3 },
  18.                                  { 4, 5, 6 },
  19.                                  { 7, 8 ,9 }
  20.                                };
  21.  
  22.             int iCalc1 = 0;
  23.             for(int i = 0; i < arrMatrix.GetLength(1); i++)
  24.             {
  25.                 iCalc1 += arrMatrix[1, i];
  26.             }
  27.  
  28.             int iCalc2 = 1;
  29.             for (int i = 0; i < arrMatrix.GetLength(0); i++)
  30.             {
  31.                 iCalc2 *= arrMatrix[i, 0];
  32.             }
  33.  
  34.             Console.SetCursorPosition(0, 0);
  35.             for (int i = 0; i < arrMatrix.GetLength(0); i++)
  36.             {
  37.                 for (int j = 0; j < arrMatrix.GetLength(1); j++)
  38.                 {
  39.                     Console.Write(arrMatrix[i, j] + " ");
  40.                 }
  41.                 Console.WriteLine();
  42.             }
  43.  
  44.             Console.WriteLine();
  45.             Console.WriteLine($"Сумма элементов второй строки: {iCalc1}");
  46.             Console.WriteLine($"Произведение элементов второй строки: {iCalc2}");
  47.             Console.ReadKey();
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement