Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Kolos2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Podaj wymiar macierzy");
- int size = Convert.ToInt32(Console.ReadLine());
- int[,] macierz = new int[size, size];
- bool check = false;
- Console.WriteLine("Podaj wartości macierzy");
- for (int row = 0; row < size; row++)
- {
- for (int col = 0; col < size; col++)
- {
- macierz[row, col] = Convert.ToInt32(Console.ReadLine());
- }
- }
- for (int row = 0; row < size; row++)
- {
- for (int col = 0; col < size; col++)
- {
- if ((row == col && macierz[row, col] == 1) || (row != col && macierz[row, col] != 1))
- check = true;
- else
- {
- check = false;
- break;
- }
- }
- }
- if (check)
- Console.WriteLine("Macierz jest jednostkowa");
- else
- Console.WriteLine("Macierz nie jest jednostkowa");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement