using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
public class ClassStack
{
private int[] mas;
private int size;
public ClassStack(int n)
{
mas = new int[n];
size = 0;
}
public void push(int el)
{
mas[size] = el;
size++;
}
public int pop()
{
size--;
return mas[size];
}
public bool empty()
{
if (size == 0)
return true;
else
return false;
}
}
class Program
{
static void Main(string[] args)
{
int[] mas = new int[10] { -2, -5, 6, 10, -2, -9, 9, -3, 12, 13 };
ClassStack stack = new ClassStack(10);
for (int i = 0; i < mas.Length; ++i)
{
if (mas[i] < 0)
{
Console.Write("{0} ", mas[i]);
}
else
{
stack.push(mas[i]);
}
}
while (stack.empty() != true)
{
Console.Write("{0} ", stack.pop());
}
}
}
}