Exemple #1
0
        private static void CircleDelete(ref LinkElem <int> head)
        {
            LinkElem <int> now = head;

            ConsoleWriteList(now);
            while (now.elem != now.next.elem)
            {
                now.next = now.next.next;
                now      = now.next;
                ConsoleWriteList(now);
            }
            head = now;
        }
Exemple #2
0
        private static void CreateCircleOfElem(int n, ref LinkElem <int> head)
        {
            LinkElem <int> now = head;

            now.elem = 1;
            int i;

            for (i = 0; i < n - 1; i++)
            {
                now.next = new LinkElem <int>(i + 2);
                now      = now.next;
            }
            now.next = head;
        }
Exemple #3
0
        static void Main(string[] args)
        {
            int            n    = 0;
            LinkElem <int> head = new LinkElem <int>();

            Console.WriteLine("Введите колличество человек");
            while (!int.TryParse(Console.ReadLine(), out n))
            {
                ;
            }
            Console.WriteLine();

            CreateCircleOfElem(n, ref head);
            CircleDelete(ref head);

            Console.WriteLine("Остался элемент под номером {0}", head.elem);
            Console.ReadKey();
        }
Exemple #4
0
 public LinkElem(T elem)
 {
     this.elem = elem;
     next      = null;
 }
Exemple #5
0
 public LinkElem(LinkElem <T> nextelem, T elem)
 {
     this.elem = elem;
     next      = nextelem;
 }
Exemple #6
0
 public LinkElem(LinkElem <T> a)
 {
     next = a;
 }
Exemple #7
0
 public LinkElem()
 {
     next = null;
 }