Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Symbol_in_Matrix
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11. char[,] matrix = new char[n, n];
  12. for (int row = 0; row < matrix.GetLength(0); row++)
  13. {
  14. var cols = Console.ReadLine()
  15. .ToCharArray();
  16. for (int col = 0; col < matrix.GetLength(1); col++)
  17. {
  18. matrix[row, col] += cols[col];
  19. }
  20. }
  21. char symbol = char.Parse(Console.ReadLine());
  22. int r = 0;
  23. int c = 0;
  24. bool isValid = false;
  25.  
  26. for (int row = 0; row < matrix.GetLength(0); row++)
  27. {
  28. for (int col = 0; col < matrix.GetLength(1); col++)
  29. {
  30. if (matrix[row,col] == symbol)
  31. {
  32. isValid = true;
  33. r = row;
  34. c = col;
  35. break;
  36. }
  37. }
  38. }
  39. if (isValid == true)
  40. {
  41. Console.WriteLine($"({r}, {c})");
  42. }
  43. else
  44. {
  45. Console.WriteLine($"{symbol} does not occur in the matrix");
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement