Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void setarray(out int[][] arr)
- {
- Console.Write("Введите кол-во строк n=");
- int n = Convert.ToInt32(Console.ReadLine());
- arr = new int[n][];
- for (int i = 0; i < arr.Length; i++)
- {
- Console.Write("Введите количество элементов в {0} строке: ", i);
- int j = int.Parse(Console.ReadLine());
- arr[i] = new int[j];
- for (j = 0; j < arr[i].Length; j++)
- {
- Console.Write("arr[{0}][{1}]= ", i, j);
- arr[i][j] = int.Parse(Console.ReadLine());
- }
- }
- }
- static void Print(int[][] a)
- {
- foreach (int[] t in a)
- Console.WriteLine(String.Join(" ", t));
- }
- static bool CheckInterval(int[][] a, int row, int inf, int sup)
- {
- for (int i = 0; i < a[row].Length; ++i)
- if (a[row][i] < inf || a[row][i] > sup)
- return false;
- return true;
- }
- static void Delete(ref int[][] a, int inf, int sup)
- {
- int i = 0;
- int len = a.Length;
- while (i < len)
- {
- if (CheckInterval(a, i, inf, sup))
- {
- int j = i;
- while (j < len - 1)
- a[j] = a[++j];
- --len;
- }
- else
- ++i;
- }
- Array.Resize(ref a, len);
- }
- static void Main()
- {
- int[][] arr;
- setarray(out arr);
- Print(arr);
- Console.Write("Введите a=");
- int a = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите a=");
- int b = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("После удаления:");
- Delete(ref arr, a, b);
- Print(arr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment