Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace AddictiveGame
- {
- class AddictiveGameSolver
- {
- public AddictiveGameSolver(int row, int col, int[] arr)
- {
- m_row = row;
- m_col = col;
- m_pos = new List<int>();
- m_pos.AddRange(arr);
- int cnt = 1;
- m_matrix = new int[row, col];
- for (int i = 0; i < m_row; ++i)
- for (int j = 0; j < m_col; ++j)
- {
- m_matrix[i, j] = cnt;
- ++cnt;
- }
- }
- public void DisplayMatrix()
- {
- for (int i = 0; i < m_row; ++i) {
- for (int j = 0; j < m_col; ++j)
- Console.Write(m_matrix[i,j] + " ");
- Console.Write("\n");
- }
- }
- public void DisplayNumbers()
- {
- foreach (int a in m_pos)
- Console.WriteLine(a);
- }
- private int m_row;
- private int m_col;
- private List<int> m_pos;
- private int[,] m_matrix;
- }
- class Program
- {
- static void Main(string[] args)
- {
- AddictiveGameSolver first = new AddictiveGameSolver(10, 10, new int[]{ 3, 4, 5, 6, 7});
- first.DisplayMatrix();
- first.DisplayNumbers();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement