Exemplo n.º 1
0
        static void dodaj(ref liczba s, int val)
        {
            liczba nowa = new liczba();

            nowa.wartosc  = val;
            nowa.nastepny = s;
            s             = nowa;
        }
Exemplo n.º 2
0
        static int zdejmij(ref liczba s)
        {
            if (s == null)
            {
                return(0);
            }

            int val = s.wartosc;

            s = s.nastepny;
            return(val);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            liczba stosik = new liczba();

            dodaj(ref stosik, 1);
            dodaj(ref stosik, 2);
            dodaj(ref stosik, 3);
            dodaj(ref stosik, 4);

            Console.WriteLine(zdejmij(ref stosik));
            Console.WriteLine(zdejmij(ref stosik));
            Console.WriteLine(zdejmij(ref stosik));
            Console.WriteLine(zdejmij(ref stosik));

            Console.ReadKey();
        }