Advertisement
loleckek228

3.3

Sep 10th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _3._3
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int userValue;
  10.             Console.CursorVisible = false;
  11.  
  12.             int[,] intArray = {
  13.                 { 0, 0, 0 },
  14.                 { 0, 0, 0 },
  15.                 { 0, 0, 0 }
  16.             };
  17.  
  18.             int sum = 0;
  19.             int product = 1;
  20.  
  21.             Console.WriteLine("Нужно составить матрицу A(3,3)");
  22.  
  23.             for (int i = 0; i < intArray.GetLength(0); i++)
  24.             {
  25.                 Console.WriteLine("Введите число: ");
  26.                 userValue = Convert.ToInt32(Console.ReadLine());
  27.                 intArray[i, 0] = userValue;
  28.                 Console.Clear();
  29.                 for (int j = 0; j < intArray.GetLength(1); j++)
  30.                 {
  31.                     Console.WriteLine("Введите число: ");
  32.                     userValue = Convert.ToInt32(Console.ReadLine());
  33.                     intArray[i, j] = userValue;
  34.  
  35.                     Console.Clear();
  36.                 }
  37.             }
  38.  
  39.             for (int i = 0; i < intArray.GetLength(0); i++)
  40.             {
  41.                 for (int j = 0; j < intArray.GetLength(1); j++)
  42.                 {
  43.  
  44.                     Console.Write(intArray[i, j] + " ");
  45.  
  46.                 }
  47.                 Console.WriteLine();
  48.             }
  49.  
  50.             for (int i = 0; i < intArray.GetLength(0); i++)
  51.             {
  52.                 product *= intArray[i, 0];
  53.             }
  54.  
  55.             for (int i = 0; i < intArray.GetLength(1); i++)
  56.             {
  57.                 sum += intArray[1, i];
  58.             }
  59.            
  60.             Console.WriteLine("Сумма второй строки: "+ sum);
  61.             Console.WriteLine("Произведение первого столбца: " + product);          
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement