Arantar, Использовать динамический массив. Т.е. ArrayList. Для этого необходимо подключить System.Collections.
ArrayList myArrayList = new ArrayList();
Затем с помощью метода Add добавляешь необходимый элемент в конец.
Скрытый текст:
Вот изменённая версия кода:
Код:
static void Main(string[] args)
{
Console.WriteLine("Введите число элементов массива а");
int size = int.Parse(Console.ReadLine());
int[] a = new int[size];
ArrayList b = new ArrayList();
ArrayList c = new ArrayList();
int k = 0;
for (int i = 0; i < size; i++)
{
Console.WriteLine("Введите элемент {0}:", i);
a[i] = int.Parse(Console.ReadLine());
if (a[i] < 0)
{
b.Add(a[i]);
}
else if (a[i] > 0)
{
c.Add(a[i]);
}
}
Console.WriteLine();
Console.Write("Первоначальный массив: ");
foreach (int j in a)
{
Console.Write(j + " ");
}
Console.WriteLine();
Console.WriteLine("Массив из отрицательных элементов массива а: ");
foreach (int j in b)
{
Console.Write(j + " ");
}
Console.WriteLine();
Console.Write("Массив из положительных элементов массива а: ");
foreach (int j in c)
{
Console.Write(j + " ");
}
Console.Read();
}