Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static int input()
- {
- int N;
- Console.WriteLine("Введите значение N - количство строк в массиве");
- while (!int.TryParse(Console.ReadLine(), out N) || N < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Вы ввели невнерный форматвходных данных\nПожалуйста, повторите ввод");
- Console.ResetColor();
- }
- return N;
- }
- static void Main(string[] args)
- {
- int N;
- do
- {
- N = input();
- Methods array = new Methods(N);
- array.Print_array();
- Console.WriteLine("Для выхода из программы нажмите Esc");
- } while (Console.ReadKey(true).Key != ConsoleKey.Escape);
- }
- }
- class Methods
- {
- public int[][] my_array;
- Random rnd = new Random();
- int new_value;
- public Methods(int N)
- {
- my_array = new int[N][];
- for (int i = 0; i < N; i++)
- {
- my_array[i] = new int[0];
- new_value = -1;
- while (new_value != 0)
- {
- new_value = rnd.Next(0, 6);
- Array.Resize(ref my_array[i], my_array[i].Length + 1);
- my_array[i][my_array[i].Length - 1] = new_value;
- Console.Write(my_array[i][my_array[i].Length - 1] + " ");
- }
- Console.WriteLine();
- }
- }
- public void Print_array()
- {
- foreach(var x in my_array)
- {
- foreach(var y in x)
- {
- Console.Write(y+" ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement