Advertisement
pifka

Symbol in Matrix

May 9th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Numerics;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9.  
  10. namespace solutions
  11. {
  12. class Program
  13. {
  14. public static void Main()
  15. {
  16. var matrixSize = int.Parse(Console.ReadLine());
  17.  
  18. var rows = matrixSize;
  19. var cols = matrixSize;
  20. var matrix = new char[rows, cols];
  21.  
  22. for (int row = 0; row < matrix.GetLength(0); row++)
  23. {
  24. var values = Console.ReadLine();
  25.  
  26. for (int col = 0; col < matrix.GetLength(1); col++)
  27. {
  28. matrix[row, col] = values[col];
  29. }
  30. }
  31.  
  32. var symbol = char.Parse(Console.ReadLine());
  33.  
  34. for (int row = 0; row < rows; row++)
  35. {
  36. for (int col = 0; col < cols; col++)
  37. {
  38. if (matrix[row, col] == symbol)
  39. {
  40. Console.WriteLine($"({row}, {col})");
  41. return;
  42. }
  43. }
  44. }
  45. Console.WriteLine($"{ symbol} does not occur in the matrix");
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement