Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 Kolos2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Podaj wymiar macierzy");
  14.             int size = Convert.ToInt32(Console.ReadLine());
  15.             int[,] macierz = new int[size, size];
  16.             bool check = false;
  17.  
  18.             Console.WriteLine("Podaj wartości macierzy");
  19.             for (int row = 0; row < size; row++)
  20.             {
  21.                 for (int col = 0; col < size; col++)
  22.                 {
  23.                     macierz[row, col] = Convert.ToInt32(Console.ReadLine());
  24.                 }
  25.             }
  26.  
  27.             for (int row = 0; row < size; row++)
  28.             {
  29.                 for (int col = 0; col < size; col++)
  30.                 {
  31.                     if ((row == col && macierz[row, col] == 1) || (row != col && macierz[row, col] != 1))
  32.                         check = true;
  33.                     else
  34.                     {
  35.                         check = false;
  36.                         break;
  37.                     }                        
  38.                 }
  39.             }
  40.  
  41.             if (check)
  42.                 Console.WriteLine("Macierz jest jednostkowa");
  43.             else
  44.                 Console.WriteLine("Macierz nie jest jednostkowa");
  45.             Console.ReadKey();
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement