ranee

сумма и произведение

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