Advertisement
Guest User

3.3

a guest
Aug 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. namespace День3Задание3
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             int sum = 0;
  8.             int prod = 1;
  9.  
  10.             int[,] A = { {5,6,1},
  11.                          {3,2,7},// <-- сумма
  12.                          {4,8,9} };
  13.             //            ^- произведение
  14.             for (int j = 0; j < A.GetLength(0) ; j++)
  15.             {
  16.                 for (int i = 0; i < A.GetLength(1) ;i++)
  17.                 {
  18.                     Console.Write(A[j,i]);
  19.                     if (j == 1)
  20.                     {
  21.                         sum += A[1, i];
  22.                     }
  23.                     if (i == 0)
  24.                     {
  25.                         prod *= A[j,0];
  26.                     }
  27.                 }
  28.                 Console.WriteLine();
  29.             }
  30.  
  31.             Console.WriteLine("sum = "+sum);
  32.             Console.WriteLine("product = "+prod);
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement