示例#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;
        }
示例#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;
        }
示例#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();
        }
示例#4
0
 public LinkElem(T elem)
 {
     this.elem = elem;
     next      = null;
 }
示例#5
0
 public LinkElem(LinkElem <T> nextelem, T elem)
 {
     this.elem = elem;
     next      = nextelem;
 }
示例#6
0
 public LinkElem(LinkElem <T> a)
 {
     next = a;
 }
示例#7
0
 public LinkElem()
 {
     next = null;
 }