Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Symbol_in_Matrix
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- char[,] matrix = new char[n, n];
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- var cols = Console.ReadLine()
- .ToCharArray();
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- matrix[row, col] += cols[col];
- }
- }
- char symbol = char.Parse(Console.ReadLine());
- int r = 0;
- int c = 0;
- bool isValid = false;
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- if (matrix[row,col] == symbol)
- {
- isValid = true;
- r = row;
- c = col;
- break;
- }
- }
- }
- if (isValid == true)
- {
- Console.WriteLine($"({r}, {c})");
- }
- else
- {
- Console.WriteLine($"{symbol} does not occur in the matrix");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement