Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace practice
- {
- class Program
- {
- static void Input (out int[] array)
- {
- Console.Write("Введите длину массива: ");
- int n = int.Parse(Console.ReadLine());
- array = new int[n];
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write("a[{0}]: ", i+1);
- array[i] = int.Parse(Console.ReadLine());
- }
- }
- static void Change(ref int[] array, int a, int b)
- {
- for (int i = 0; i < array.Length; i++)
- if (array[i] <= b && array[i] >= a)
- {
- for (int j = i; j < array.Length - 1; j++)
- array[j] = array[j+1];
- Array.Resize(ref array, array.Length - 1);
- }
- }
- static void Print(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- Console.Write("{0} ", array[i]);
- }
- static void Main(string[] args)
- {
- int[] array;
- Console.WriteLine("Введите заданный промежуток: ");
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- Input(out array);
- Change(ref array, a, b);
- Print(array);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement