Advertisement
slemiba

L04-02 Determináns

Sep 27th, 2022
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SzTFLabor04
  4. {
  5.     class Program
  6.     {
  7.         static void Matrix_Ki(ref int[,] mat)
  8.         {
  9.             for (int j = 0; j < 2; j++)
  10.             {
  11.                 Console.Write("|");
  12.                 for (int i = 0; i < 2; i++)
  13.                 {
  14.                     Console.Write(mat[j,i]);
  15.                     if (i == 0)
  16.                     {
  17.                         Console.Write(" ");
  18.                     }
  19.                 }
  20.                 Console.WriteLine("|");
  21.             }
  22.            
  23.         }
  24.  
  25.         static int detM(ref int[,] mat)
  26.         {
  27.             return mat[0, 0] * mat[1, 1] - mat[0,1]*mat[1,0];
  28.         }
  29.        
  30.         static void Main(string[] args)
  31.         {
  32.             Console.ForegroundColor = ConsoleColor.Black;
  33.             Console.BackgroundColor = ConsoleColor.White;
  34.             Console.Title = "SzTFLabor";
  35.             Console.Clear();
  36.  
  37.             int[,] M = new int[2,2];
  38.  
  39.             for (int i = 0; i < 4; i++)
  40.             {
  41.                 Console.Write($"{i}. elem: ");
  42.                 int a = int.Parse(Console.ReadLine());
  43.                 M[i / 2,i % 2] = a;
  44.             }
  45.  
  46.             Matrix_Ki(ref M);
  47.             Console.Write(detM(ref M));
  48.  
  49.  
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement