Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
51
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.Collections.Generic;
  3.  
  4. namespace AddictiveGame
  5. {
  6. class AddictiveGameSolver
  7. {
  8. public AddictiveGameSolver(int row, int col, int[] arr)
  9. {
  10. m_row = row;
  11. m_col = col;
  12. m_pos = new List<int>();
  13. m_pos.AddRange(arr);
  14. int cnt = 1;
  15. m_matrix = new int[row, col];
  16. for (int i = 0; i < m_row; ++i)
  17. for (int j = 0; j < m_col; ++j)
  18. {
  19. m_matrix[i, j] = cnt;
  20. ++cnt;
  21. }
  22. }
  23.  
  24. public void DisplayMatrix()
  25. {
  26. for (int i = 0; i < m_row; ++i) {
  27. for (int j = 0; j < m_col; ++j)
  28. Console.Write(m_matrix[i,j] + " ");
  29. Console.Write("\n");
  30. }
  31. }
  32.  
  33. public void DisplayNumbers()
  34. {
  35. foreach (int a in m_pos)
  36. Console.WriteLine(a);
  37. }
  38.  
  39. private int m_row;
  40. private int m_col;
  41. private List<int> m_pos;
  42. private int[,] m_matrix;
  43. }
  44.  
  45. class Program
  46. {
  47. static void Main(string[] args)
  48. {
  49. AddictiveGameSolver first = new AddictiveGameSolver(10, 10, new int[]{ 3, 4, 5, 6, 7});
  50. first.DisplayMatrix();
  51. first.DisplayNumbers();
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement