<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3264828</guid>
        <pubDate>Thu, 24 Jan 2013 06:30:41 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3264828</link>
        <description><![CDATA[kotmatroskin55: На всякий случай решил выложить. Может кому сгодится, ну или появится желание покритиковать. Эту задачу я сдал. 1 курс матфака ОмГУ<br>
<span class="b-attach" data-size="5041" data-hits="126" data-attach-id="26622" data-attach-post-id="3264828">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3264828&amp;attach_id=26622' title='Скачать файл' target='_blank'>очередь.rar</a> (, : 126)
		</span>]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3214269</guid>
        <pubDate>Thu, 04 Oct 2012 10:27:48 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3214269</link>
        <description><![CDATA[kotmatroskin55: Всем спасибо. Вопрос решен]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151345</guid>
        <pubDate>Fri, 08 Jun 2012 10:34:39 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151345</link>
        <description><![CDATA[kotmatroskin55: кажись разобрался,осталось доделать процедуру сравнения,но это уже мелочи]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151306</guid>
        <pubDate>Fri, 08 Jun 2012 09:34:59 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151306</link>
        <description><![CDATA[volvo877: Знаешь, я второй раз то же самое писать не буду - перечитай мои посты выше и переделай алгоритм, потом будем продолжать. Этот код неверный.]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151305</guid>
        <pubDate>Fri, 08 Jun 2012 09:31:41 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151305</link>
        <description><![CDATA[kotmatroskin55: попробовал - ничего хорошего не выходит,пишет пустая очередь<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure Queue.change(qu1,qu2:Queue;var qu_rez:Queue);</div><div class="code_line">var</div><div class="code_line">p:L1_List;</div><div class="code_line">x,y:TElem;</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; while not lst.IsEmpty do</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;x:=qu1.get_que;</div><div class="code_line">&nbsp;&nbsp; &nbsp;y:=qu2.get_que;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if x&#62;=y then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(x);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(y);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(y);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(x);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;&nbsp;end;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151287</guid>
        <pubDate>Fri, 08 Jun 2012 09:08:00 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151287</link>
        <description><![CDATA[volvo877: Обычно у списка есть готовый метод, проверяющий его на пустоту. У тебя в первом сообщении он назывался IsEmptyList, у меня в №15 - IsEmpty. Вот его и вызывай для проверки.]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151262</guid>
        <pubDate>Fri, 08 Jun 2012 08:39:52 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151262</link>
        <description><![CDATA[kotmatroskin55: если честно не особо: не могу понять, как проверить закончилась ли очередь:так что ли<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">while lst.head&#60;&#62;nil do</div></ol></div></div></div></div>]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151134</guid>
        <pubDate>Fri, 08 Jun 2012 05:12:30 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151134</link>
        <description><![CDATA[volvo877: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3151131'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kotmatroskin55 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-08T04:35:49+00:00">08.06.12, 04:35</time></span><div class='quote '>//вот здесь должен быть цикл,типа пока обе очереди не станут пустыми</div></div><br>
Это неправильное предположение. Цикл должен быть до тех пор, пока ОДНА из очередей не станет пустой. Как только одна очередь пустая - выходишь из цикла и потом просто дописываешь в очередь-результат содержимое непустой очереди. Это было первое. Второе: не надо сразу писать и X и Y в очередь-результат. Иначе при вот таких данных:<br>
<br>
1: &lt;1, 2, 6, 8&gt;<br>
2: &lt;5, 7&gt;<br>
ты получишь неправильный результат: у тебя первые 2 элемента первой очереди меньше, чем первый элемент второй (а твой алгоритм запишет 1, 5 в результирующую очередь), поэтому надо писать в qu_rez только МЕНЬШЕЕ из значений. Идею понимаешь? :)]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151131</guid>
        <pubDate>Fri, 08 Jun 2012 04:35:49 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3151131</link>
        <description><![CDATA[kotmatroskin55: Наверное последний вопрос в этой теме: написал процедуру обработки,которая решает поставленную задачу,все робит,только не могу сообразить как правильно организовать цикл. Подскажите пожалуйста. :wall:  :wall:  :wall:  :wall:  :wall: вот код:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure Queue.change(qu1,qu2:Queue;var qu_rez:Queue);</div><div class="code_line">var</div><div class="code_line">p:L1_List;</div><div class="code_line">x,y:TElem;</div><div class="code_line">&nbsp;&nbsp;begin//вот здесь должен быть цикл,типа пока обе очереди не станут пустыми</div><div class="code_line">&nbsp;&nbsp; &nbsp;x:=qu1.get_que;</div><div class="code_line">&nbsp;&nbsp; &nbsp;y:=qu2.get_que;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if x&#62;=y then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(x);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(y);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(y);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; qu_rez.put_que(x);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp;end;</div></ol></div></div></div></div>]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150322</guid>
        <pubDate>Wed, 06 Jun 2012 14:11:04 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150322</link>
        <description><![CDATA[kotmatroskin55: И еще один вопросик: как организовать обработку ошибок с помощью маски?,честно говоря не понял вообще]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150028</guid>
        <pubDate>Wed, 06 Jun 2012 08:09:13 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150028</link>
        <description><![CDATA[Vesper: RTFM: <a class='tag-url' href='http://ru.wikipedia.org/wiki/%D0%9A%D0%BB%D0%B0%D1%81%D1%81_%28%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5%29' target='_blank'>тут</a>, и на лекциях должны рассказывать. Вкратце: public доступен откуда хочешь, private доступен только из методов самого класса и больше ниоткуда, protected еще доступен из методов потомков класса, если они есть. И ругается именно поэтому, head в твоем L1_List не паблик, а достать хочешь из не связанного никак Queue.]]></description>
        <author>Vesper</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150011</guid>
        <pubDate>Wed, 06 Jun 2012 07:51:37 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3150011</link>
        <description><![CDATA[kotmatroskin55: еще два вопроса:<br>
1. чем отличается &quot;private&quot; от &quot;protected&quot;;<br>
2. и еще компилятор страшно ругается вот на это:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function Queue.Get_Que:TElem;//взять элемент из очереди</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if Lst.IsEmpty then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Get_Que := Lst.head^.data;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Lst.RemoveAt (Lst.head);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div></ol></div></div></div></div><br>
вот так: Error: identifier idents no member &quot;head&quot;]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149643</guid>
        <pubDate>Tue, 05 Jun 2012 14:16:57 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149643</link>
        <description><![CDATA[kotmatroskin55: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3149574'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Vesper &#064; <time class="tag-quote__quoted-time" datetime="2012-06-05T12:37:13+00:00">05.06.12, 12:37</time></span><div class='quote '><div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3149568'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>volvo877 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-05T12:24:32+00:00">05.06.12, 12:24</time></span><div class='quote '>А ты знаешь, агрегацию тоже никто не отменял</div></div></div></div><br>
вопрос:получается те процедуры,что я написал - неправильные или как? <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-06-05T14:23:49+00:00">05.06.12, 14:23</time></span></span><br>
Извини,сам понял, что вопрос предельно глупый]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149586</guid>
        <pubDate>Tue, 05 Jun 2012 12:55:33 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149586</link>
        <description><![CDATA[kotmatroskin55: Очень даже понятно,просто я сам только сегодня узнал.что наследование использовать нельзя. с одной стороны - правильно - необходимо со всеми этими делами как следует разобраться, а с другой - пользователю же все равно  сколько и чего используется в программе - главное чтоб сама прога работала нормально.]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149568</guid>
        <pubDate>Tue, 05 Jun 2012 12:24:32 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149568</link>
        <description><![CDATA[volvo877: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3149486'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kotmatroskin55 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-05T10:31:21+00:00">05.06.12, 10:31</time></span><div class='quote '>Кстати,мне сказали,что наследование использовать нельзя: &quot;Вы еще до этого не доросли&quot;</div></div>А ты знаешь, агрегацию тоже никто не отменял:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp; TQueue =</div><div class="code_line">&nbsp;&nbsp; object</div><div class="code_line">&nbsp;&nbsp; private</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Lst : TList;</div><div class="code_line">&nbsp;&nbsp; public</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;constructor Create;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;destructor Destroy; virtual;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Put (X : TItem);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;function Get : TItem;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Print;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">// ...</div><div class="code_line">&nbsp;</div><div class="code_line">constructor TQueue.Create;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; Lst.Create;</div><div class="code_line">end;</div><div class="code_line">destructor TQueue.Destroy;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; Lst.Destroy;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TQueue.Put (X : TItem);</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; Lst.Append (X);</div><div class="code_line">end;</div><div class="code_line">function TQueue.Get : TItem;</div><div class="code_line">var T : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; if Lst.IsEmpty then WriteLn(&#39;&#60;&#62;&#39;)</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Get := Lst.head^.data;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Lst.RemoveAt (Lst.head);</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TQueue.Print;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; Lst.Print;</div><div class="code_line">end;</div></ol></div></div></div></div>, остальная часть программы не меняется. Наследования нет, функционал абсолютно такой же, как и при наследовании. :)]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149486</guid>
        <pubDate>Tue, 05 Jun 2012 10:31:21 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149486</link>
        <description><![CDATA[kotmatroskin55: понял,благодарю. Кстати,мне сказали,что наследование использовать нельзя: &quot;Вы еще до этого не доросли&quot;. Сейчас попробую разобраться.]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149411</guid>
        <pubDate>Tue, 05 Jun 2012 09:05:12 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149411</link>
        <description><![CDATA[volvo877: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3149295'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kotmatroskin55 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-05T06:44:52+00:00">05.06.12, 06:44</time></span><div class='quote '>написал процедуры для работы с очередью на основе односвязного списка. </div></div>Ты написал процедуры НЕ на основе односвязного списка, а отдельные. Наследование у тебя тут - никаким боком не используется. Если б ты не тратил лишнее время (и память, кстати, тоже) на работу с этим на фиг никому не нужным заглавным звеном (великое, блин счастье, выделить память под пустой элемент, а потом везде в программе обходить разложенные этим простым и незатейливым действием фугасы, которые могут в любой момент рвануть так, что мало не покажется) - то все было бы просто до безобразия:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">// Модуль:</div><div class="code_line">// (недостающие методы реализуешь сам, они для решения текущей задачи не важны)</div><div class="code_line">unit L;</div><div class="code_line">&nbsp;</div><div class="code_line">interface</div><div class="code_line">&nbsp;</div><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp; TItem = Integer;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; Link = ^Node;</div><div class="code_line">&nbsp;&nbsp; Node =</div><div class="code_line">&nbsp;&nbsp; record</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;data : TItem;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;next : Link;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; TList =</div><div class="code_line">&nbsp;&nbsp; object</div><div class="code_line">&nbsp;&nbsp; protected</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;head, tail : Link;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; public</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;constructor Create;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;destructor Destroy; virtual;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Append (X : TItem); // to the end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Insert (X : TItem); // to the beginning</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure InsertAfter (p : Link; X : TItem); // insert X after p^</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;function Find (x : TItem) : Link;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure RemoveAt (p : Link);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;function IsEmpty : boolean;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Print;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;// ...</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; TQueue =</div><div class="code_line">&nbsp;&nbsp; object (TList)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;constructor Create;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;destructor Destroy; virtual;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;procedure Put (X : TItem);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;function Get : TItem;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">implementation</div><div class="code_line">&nbsp;</div><div class="code_line">constructor TList.Create;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; head := nil;</div><div class="code_line">&nbsp;&nbsp; tail := nil;</div><div class="code_line">end;</div><div class="code_line">destructor TList.Destroy;</div><div class="code_line">var p : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; while head &#60;&#62; nil do</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;p := head;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;head := head^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;dispose(p);</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TList.Append (X : TItem); // to the end</div><div class="code_line">var p : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; new(p);</div><div class="code_line">&nbsp;&nbsp; p^.next := nil;</div><div class="code_line">&nbsp;&nbsp; p^.data := X;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; if IsEmpty then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;head := p</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;tail^.next := p;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; tail := p;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TList.Insert (X : TItem); // to the beginning</div><div class="code_line">var p : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; new(p);</div><div class="code_line">&nbsp;&nbsp; p^.next := head;</div><div class="code_line">&nbsp;&nbsp; p^.data := X;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; if IsEmpty then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;tail := p;</div><div class="code_line">&nbsp;&nbsp; head := p;</div><div class="code_line">end;</div><div class="code_line">procedure TList.InsertAfter (p : Link; X : TItem); // insert X after p^</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; //</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">function TList.Find (x : TItem) : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; //</div><div class="code_line">end;</div><div class="code_line">function TList.IsEmpty : boolean;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; IsEmpty := head = nil;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TList.RemoveAt (p : Link);</div><div class="code_line">var pp : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; if p = head then</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;pp := head;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;head := head^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;dispose(pp);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if head = nil then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; tail := nil;</div><div class="code_line">&nbsp;&nbsp; end</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;pp := head;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while (pp^.next &#60;&#62; nil) and (pp^.next &#60;&#62; p) do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; pp := pp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if Assigned (pp) then // found</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; pp^.next := p^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; dispose(p);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TList.Print;</div><div class="code_line">var p : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; p := head;</div><div class="code_line">&nbsp;&nbsp; write(&#39;&#60;&#39;);</div><div class="code_line">&nbsp;&nbsp; while p &#60;&#62; nil do</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;write (p^.data:3);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;p := p^.next;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;&nbsp; writeln(&#39;&#62;&#39;);</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">constructor TQueue.Create;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; inherited;</div><div class="code_line">end;</div><div class="code_line">destructor TQueue.Destroy;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; inherited;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TQueue.Put (X : TItem);</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; Append (X);</div><div class="code_line">end;</div><div class="code_line">function TQueue.Get : TItem;</div><div class="code_line">var T : Link;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; if IsEmpty then WriteLn(&#39;&#60;&#62;&#39;)</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Get := head^.data;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;RemoveAt (head);</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">end.</div></ol></div></div></div></div><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">// тестовая программа:</div><div class="code_line">uses crt, L;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; i : Integer;</div><div class="code_line">&nbsp;&nbsp; x : TItem;</div><div class="code_line">&nbsp;&nbsp; q : TQueue;</div><div class="code_line">&nbsp;&nbsp; ls : tlist;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; ls.Create;</div><div class="code_line">&nbsp;&nbsp; for i := 1 to 10 do</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;ls.Insert(2 * i);</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;&nbsp; ls.Print;</div><div class="code_line">&nbsp;&nbsp; ls.Destroy;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; q.Create;</div><div class="code_line">&nbsp;&nbsp; for i := 1 to 10 do</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;q.Put(i);</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; q.Print;</div><div class="code_line">&nbsp;&nbsp; writeln(q.Get);</div><div class="code_line">&nbsp;&nbsp; writeln(q.Get);</div><div class="code_line">&nbsp;&nbsp; writeln(q.Get);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; q.Print;</div><div class="code_line">&nbsp;&nbsp; q.Destroy;</div><div class="code_line">&nbsp;&nbsp; readln;</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149395</guid>
        <pubDate>Tue, 05 Jun 2012 08:21:52 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149395</link>
        <description><![CDATA[Vesper: Если тебе позарез нужны методы L1_List, нужно использовать Que как объект, одним из элементов которого является список как структура данных. Тогда метод Put будет реализован через AddElem(хвост) и смещение хвоста, а Get (как из начала очереди) через удаление головы.]]></description>
        <author>Vesper</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149382</guid>
        <pubDate>Tue, 05 Jun 2012 08:03:23 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149382</link>
        <description><![CDATA[kotmatroskin55: и еще вопросик:как с помощью методов для списка создавать очередь, если они идут как бы сами по себе,т.е. от методов L1_List не особо зависят. чего-то я не совсем в теме-литературы море перекопал,но толку пока не очень.]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149305</guid>
        <pubDate>Tue, 05 Jun 2012 06:53:51 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149305</link>
        <description><![CDATA[Vesper: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3149295'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kotmatroskin55 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-05T06:44:52+00:00">05.06.12, 06:44</time></span><div class='quote '>Вопрос: позволит ли мне паскаль хранить в памяти несколько очередей? </div></div><br>
В динамической памяти может поместиться довольно много объектов для такой задачи. Считай, что позволит, и из этого пиши дальше. На всякий случай можешь посмотреть результат функции MemAvail до и во время выполнения программы, чтобы оценить максимальную длину очередей.]]></description>
        <author>Vesper</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149295</guid>
        <pubDate>Tue, 05 Jun 2012 06:44:52 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3149295</link>
        <description><![CDATA[kotmatroskin55: написал процедуры для работы с очередью на основе односвязного списка. <br>
вроде вот так как-то:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">unit L1_sp;</div><div class="code_line">interface</div><div class="code_line">uses crt;</div><div class="code_line">type</div><div class="code_line">TElem=integer;</div><div class="code_line">TFile=file of TElem;</div><div class="code_line">Link=^ListElem;</div><div class="code_line">ListElem=record</div><div class="code_line">&nbsp;&nbsp; Data:TElem;</div><div class="code_line">&nbsp;&nbsp; next:Link;</div><div class="code_line">end;</div><div class="code_line">TQueue = record // структура для реализации очереди</div><div class="code_line">&nbsp;&nbsp;first: Link; // указатель, указывает на первый элемент очереди</div><div class="code_line">&nbsp;&nbsp;last: Link; // указатель, указывает на последний элемент очереди</div><div class="code_line">end;</div><div class="code_line">L1_List=object</div><div class="code_line">&nbsp;&nbsp;private</div><div class="code_line">&nbsp;&nbsp; &nbsp;head:Link;//голова</div><div class="code_line">&nbsp;&nbsp; &nbsp;Temp:Link;//указатель на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;//err_code:word; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;public</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CreateList;//создание списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CopyList(var List:L1_List);//копирование</div><div class="code_line">&nbsp;&nbsp; &nbsp;destructor Destroy_List;//удаление с очисткой памяти</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ClearList;//очистка текущуго списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;function IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutTempForvard;//вправо</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure InBegin;//в начало</div><div class="code_line">&nbsp;&nbsp; &nbsp;//function IsTempLast:boolean;</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutElem(var x:TElem);//вставка элемента за указатель</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure GetElem(var x:TElem);//</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure LookElem(var x:TElem);//посмотреть элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ChangeElem(var x:TElem);//изменить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure DelElem(var x:TElem);//удалить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;//procedure GetError;</div><div class="code_line">&nbsp;&nbsp; // procedure MaskError(eror:word);</div><div class="code_line">&nbsp;&nbsp; // procedure ClearMaskErr;</div><div class="code_line">end;</div><div class="code_line">Queue=object(L1_List)</div><div class="code_line">&nbsp;&nbsp;private</div><div class="code_line">&nbsp;&nbsp; &nbsp;Que:TQueue;</div><div class="code_line">&nbsp;&nbsp; &nbsp;eprst:boolean;</div><div class="code_line">&nbsp;&nbsp;public</div><div class="code_line">&nbsp;&nbsp;procedure Put_Que(var x: TElem); &nbsp;//добавление элемента в очередь</div><div class="code_line">&nbsp;&nbsp;procedure Get_Que(var x:TElem);</div><div class="code_line">&nbsp;&nbsp;procedure Print_Que;</div><div class="code_line">&nbsp;end; &nbsp; </div><div class="code_line">//********************************</div><div class="code_line">implementation</div><div class="code_line">//********************************</div><div class="code_line">constructor L1_List.CreateList;//</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;new(head);//выделяем память</div><div class="code_line">&nbsp;&nbsp; &nbsp;head^.next:=nil;//направляем указатель в nil</div><div class="code_line">&nbsp;&nbsp; &nbsp;temp:=head;</div><div class="code_line">&nbsp;end;</div><div class="code_line">//****************************************</div><div class="code_line">Destructor L1_List.Destroy_List;//</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; while head&#60;&#62;NIL do//пока голова не укаывает в nil</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; temp:=head;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; head:=head^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; dispose(temp);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; dispose(head); &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//***************************************</div><div class="code_line">procedure L1_List.InBegin;//в начало </div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; Temp:=head^.next;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//****************************************</div><div class="code_line">procedure L1_List.PutElem(var x:TElem);//добавить элемент после указателя</div><div class="code_line">var</div><div class="code_line">&nbsp;NewEl:Link;</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; new(NewEl);//выделяем память под новый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; NewEl^.data:=x;// записываем в него данные</div><div class="code_line">&nbsp;&nbsp; &nbsp; {Если список был пустой, то головой списка становится p}</div><div class="code_line">&nbsp;&nbsp; &nbsp; if head^.next=NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; NewEl^.next:= nil;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; head:=NewEl;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NewEl^.next:=Temp^.next;{ в новом элементе делаем ссылку</div><div class="code_line">на следующий элемент, который был до вставки}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Temp^.next:=NewEl;{в текущем элементе делаем ссылку на новый} &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; head:=Temp^.next;// текущим становится новый элемент</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.PutTempForvard;//двигаем указатель вправо</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; temp:=temp^.next</div><div class="code_line">&nbsp;&nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.DelElem(var x:TElem); &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp; p,p1:Link;//p1 - предыдущий элемент </div><div class="code_line">&nbsp;&nbsp; power:boolean; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;power:=true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while true do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.data = x then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; power:= true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.next = nil then break</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1:= p;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= p^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if power then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p = head then // если удаляется первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= head^.next; // запоминаем ссылку на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(head); // удаляем первый элемент списка</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;head:= p; // головой списка становится p</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin // если удаляется не первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1^.next:= p^.next; { в предыдущем элементе заменяем</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ссылку на следующий элемент после удаляемого }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(p);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp:= p1; // текущим делаем предыдущий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">constructor L1_List.CopyList(var List:L1_List);</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.ClearList;//очистить текущий список</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp;tmp:Link; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;tmp:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while tmp &#60;&#62; NIL do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;head:=tmp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmp:=tmp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(head);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Dispose(tmp);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">//***********************************************</div><div class="code_line">function L1_List.IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next = NIL then IsEmptyList:=false</div><div class="code_line">&nbsp;&nbsp; &nbsp;else IsEmptyList:=true;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.ChangeElem(var x:TElem);//изменение элемента за указателем</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then temp^.data:=x</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.LookElem(var x:TElem);//посмотреть элемент после указателя</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:=temp^.data; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.GetElem(var x:TElem); &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:=temp^.data; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dispose(temp);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure Queue.Put_Que(var x: TElem); &nbsp;//добавление элемента в очередь</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;pont:Link;//временный указатель</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if Que.last=nil then{Если очередь пуста, то указатели на первый и последний элемент будут совпадать}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.last:= New(Link);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.first:= Que.last; // Приравниваем указатели</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.last^.data:= x;//записываем данные</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.last^.next:= nil; // Следующий элемент пока пустой &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pont:=New(Link);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pont^.data:=x;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pont^.next:=nil;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.last^.next:=pont;//ссылка на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Que.last:=pont;//сдвигаем указатель на последний элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure Queue.Get_Que(var x:TElem);//взять элемент из очереди</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp; &nbsp;pont:Link;</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if Que.first=nil then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;eprst:=true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:=Que.first^.data;//первывй элемент очереди</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pont:=Que.first;//запомним ссылку</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Que.first:=Que.first^.next;//переход на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dispose(pont);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">procedure Queue.Print_Que;</div><div class="code_line">&nbsp;&nbsp;var </div><div class="code_line">&nbsp;&nbsp; &nbsp;pont:Link;</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;pont:=Que.first;//берем первый элемент очереди,в цикле проходим все элементы очереди и печатаем их</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while pont&#60;&#62;nil do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;write(pont^.data,&#39; &#39;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pont:=pont^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;writeln;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">end.</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-06-05T06:49:16+00:00">05.06.12, 06:49</time></span></span><br>
только теперь не могу сообразить с какого боку подойти к решению задачи. Получается для начала нужно создать две очереди, выделить память под третью, а затем с помощью методов Put и Get каким-то макаром заполнить третью. Вопрос: позволит ли мне паскаль хранить в памяти несколько очередей?]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148578</guid>
        <pubDate>Mon, 04 Jun 2012 06:45:10 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148578</link>
        <description><![CDATA[volvo877: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=358468&view=findpost&p=3148541'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kotmatroskin55 &#064; <time class="tag-quote__quoted-time" datetime="2012-06-04T06:14:40+00:00">04.06.12, 06:14</time></span><div class='quote '>Я так понимаю,для выполнения задания еще нужно будет добавить процедуру поиска элемента?</div></div>Я так понимаю, ты не хочешь читать посты? Нет и не может быть для очереди никакого поиска элементов. Только 2 метода (не включая конструктора/деструктора) - Put и Get. Первый добавляет элемент в хвост очереди, второй - извлекает из головы. Всё. Про все остальные методы (типа поиска, сортировки, получения НЕ головного элемента) забудь. Их не существует.<br>
<br>
Вот у тебя и задача: используя только методы Put/Get, крутись как хочешь, но из двух упорядоченных очередей (создавать сразу упорядоченную, либо упорядочивать, <strong class='tag-b'>используя только эти 2 метода</strong> - дело твоё) создай третью, которая тоже упорядочена.]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148541</guid>
        <pubDate>Mon, 04 Jun 2012 06:14:40 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148541</link>
        <description><![CDATA[kotmatroskin55: задание такое:<br>
&quot;Даны две очереди целых чисел, элементы которых упорядочены по неубыванию. Составить из их элементов третью очередь, упорядоченную по невозрастанию&quot;<br>
там был еще компилятор, но я не стал его брать - времени в обрез. <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-06-04T06:21:08+00:00">04.06.12, 06:21</time></span></span><br>
Я так понимаю,для выполнения задания еще нужно будет добавить процедуру поиска элемента? А еще не решил как создавать исходные очереди - вручную - с проверкой неубывания, или пусть пользователь забивает ее как хочет, а потом самому сортировать обе очереди, и оттуда уже плясать. Что посоветуешь?]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148522</guid>
        <pubDate>Mon, 04 Jun 2012 05:53:57 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148522</link>
        <description><![CDATA[volvo877: Это смотря какое у тебя задание. Можно и наследника в этом же модуле сделать. Можно и наследника в отдельном модуле :)]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148517</guid>
        <pubDate>Mon, 04 Jun 2012 05:49:55 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148517</link>
        <description><![CDATA[kotmatroskin55: И еще вопросик: как лучше сделать реализацию очереди - написать объект - наследник L1_List?или проще будет отдельный модуль написать?]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148511</guid>
        <pubDate>Mon, 04 Jun 2012 05:39:37 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148511</link>
        <description><![CDATA[kotmatroskin55: все понял.от души. <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-06-04T05:42:17+00:00">04.06.12, 05:42</time></span></span><br>
все это финиш..............................................................]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148499</guid>
        <pubDate>Mon, 04 Jun 2012 05:14:12 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148499</link>
        <description><![CDATA[volvo877: <div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; x:TElem;</div><div class="code_line">&nbsp;&nbsp; lst : L1_List;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; lst.CreateList; // Создавать надо ЭКЗЕМПЛЯР</div><div class="code_line">&nbsp;&nbsp; readln(x);</div><div class="code_line">&nbsp;&nbsp; lst.PutElem(x);</div><div class="code_line">&nbsp;&nbsp; readln;</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148489</guid>
        <pubDate>Mon, 04 Jun 2012 04:50:24 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3148489</link>
        <description><![CDATA[kotmatroskin55: :wall:  :wall:  :wall:  :wall:  :wall:  :wall:  :wall: <br>
попробовал написать тестирующую для списка - казалось бы - чего сложного то, но компилятор ругается на методы вот так:<br>
&quot;Error: Only static variables can be used in static methods or outside methods&quot;<br>
вот код тестирующей - там три строчки - засел на создании списка.<br>
опять наверное какая-нибудь мелочь - подскажите пожалуйста<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">program L1_Test;</div><div class="code_line">uses crt,L1_sp;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; &nbsp;x:TElem;</div><div class="code_line">begin</div><div class="code_line">L1_List.CreateList;</div><div class="code_line">readln(x);</div><div class="code_line">L1_List.PutElem(x);</div><div class="code_line">readln;</div><div class="code_line">end.</div></ol></div></div></div></div><br>
вот код модуля<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">unit L1_sp;</div><div class="code_line">interface</div><div class="code_line">uses crt;</div><div class="code_line">type</div><div class="code_line">TElem=integer;</div><div class="code_line">TFile=file of TElem;</div><div class="code_line">Link=^ListElem;</div><div class="code_line">ListElem=record</div><div class="code_line">&nbsp;&nbsp; Data:TElem;</div><div class="code_line">&nbsp;&nbsp; next:Link;</div><div class="code_line">end;</div><div class="code_line">L1_List=object</div><div class="code_line">&nbsp;&nbsp;private</div><div class="code_line">&nbsp;&nbsp; &nbsp;head:Link;//голова</div><div class="code_line">&nbsp;&nbsp; &nbsp;Temp:Link;//указатель на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;//err_code:word; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;public</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CreateList;//создание списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CopyList(var List:L1_List);//копирование</div><div class="code_line">&nbsp;&nbsp; &nbsp;destructor Destroy_List;//удаление с очисткой памяти</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ClearList;//очистка текущуго списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;function IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutTempForvard;//вправо</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure InBegin;//в начало</div><div class="code_line">&nbsp;&nbsp; &nbsp;//function IsTempLast:boolean;</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutElem(var x:TElem);//вставка элемента за указатель</div><div class="code_line">&nbsp;&nbsp; // procedure GetElem(var x:TElem);//</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure LookElem(var x:TElem);//посмотреть элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ChangeElem(var x:TElem);//изменить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure DelElem(var x:TElem);//удалить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;//procedure GetError;</div><div class="code_line">&nbsp;&nbsp; // procedure MaskError(eror:word);</div><div class="code_line">&nbsp;&nbsp; // procedure ClearMaskErr;</div><div class="code_line">end;</div><div class="code_line">implementation</div><div class="code_line">//********************************</div><div class="code_line">constructor L1_List.CreateList;//</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;new(head);//выделяем память</div><div class="code_line">&nbsp;&nbsp; &nbsp;head^.next:=nil;//направляем указатель в nil</div><div class="code_line">&nbsp;&nbsp; &nbsp;temp:=head;</div><div class="code_line">&nbsp;end;</div><div class="code_line">//****************************************</div><div class="code_line">Destructor L1_List.Destroy_List;//</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; while head&#60;&#62;NIL do//пока голова не укаывает в nil</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; temp:=head;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; head:=head^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; dispose(temp);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; dispose(head); &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//***************************************</div><div class="code_line">procedure L1_List.InBegin;//в начало </div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; Temp:=head^.next;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//****************************************</div><div class="code_line">procedure L1_List.PutElem(var x:TElem);//добавить элемент после указателя</div><div class="code_line">var</div><div class="code_line">&nbsp;NewEl:Link;</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; new(NewEl);//выделяем память под новый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; NewEl^.data:=x;// записываем в него данные</div><div class="code_line">&nbsp;&nbsp; &nbsp; {Если список был пустой, то головой списка становится p}</div><div class="code_line">&nbsp;&nbsp; &nbsp; if head^.next=NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; NewEl^.next:= nil;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; head:=NewEl;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NewEl^.next:=Temp^.next;{ в новом элементе делаем ссылку</div><div class="code_line">на следующий элемент, который был до вставки}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Temp^.next:=NewEl;{в текущем элементе делаем ссылку на новый} &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; head:=Temp^.next;// текущим становится новый элемент</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.PutTempForvard;//двигаем указатель вправо</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; temp:=temp^.next</div><div class="code_line">&nbsp;&nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.DelElem(var x:TElem); &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp; p,p1:Link;//p1 - предыдущий элемент </div><div class="code_line">&nbsp;&nbsp; power:boolean; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;power:=true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while true do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.data = x then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; power:= true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.next = nil then break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1:= p;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= p^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if power then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p = head then // если удаляется первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= head^.next; // запоминаем ссылку на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(head); // удаляем первый элемент списка</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;head:= p; // головой списка становится p</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin // если удаляется не первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1^.next:= p^.next; { в предыдущем элементе заменяем</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ссылку на следующий элемент после удаляемого }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(p);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp:= p1; // текущим делаем предыдущий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">constructor L1_List.CopyList(var List:L1_List);</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.ClearList;//очистить текущий список</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp;tmp:Link; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;tmp:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while tmp &#60;&#62; NIL do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;head:=tmp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmp:=tmp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(head);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Dispose(tmp);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">//***********************************************</div><div class="code_line">function L1_List.IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next = NIL then IsEmptyList:=false</div><div class="code_line">&nbsp;&nbsp; &nbsp;else IsEmptyList:=true;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.ChangeElem(var x:TElem);//изменение элемента за указателем</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then temp^.data:=x</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.LookElem(var x:TElem);//посмотреть элемент после указателя</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:=temp^.data; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">end.</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-06-04T05:08:20+00:00">04.06.12, 05:08</time></span></span><br>
и еще забыл сказать, что список я решил делать обычный, а не кольцевой]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3147519</guid>
        <pubDate>Sat, 02 Jun 2012 06:43:32 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3147519</link>
        <description><![CDATA[volvo877: Насчет самого списка -реализации уже были в этом разделе, я выкладывал точно - посмотри.<br><br>А насчет очереди - зачем тебе 2 списка для каждой очереди? Нужно на каждую очередь один список, метод Put очереди будет добавлять элемент перед начальным (новый элемент будет указывать полем Next на начальный), метод Get - будет получать значение начального элемента списка (и удалять его). Вот тебе и очередь.]]></description>
        <author>volvo877</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3147496</guid>
        <pubDate>Sat, 02 Jun 2012 04:24:46 +0000</pubDate>
        <title>Очередь на основе односвязного кольцевого списка</title>
        <link>https://forum.sources.ru/index.php?showtopic=358468&amp;view=findpost&amp;p=3147496</link>
        <description><![CDATA[kotmatroskin55: А вот как создать очередь на его основе, пока не придумал,я так понимаю, что надо будет создать  в памяти по два списка для каждой<br>
очереди? или я неправ?<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">unit L1_sp;</div><div class="code_line">interface</div><div class="code_line">uses crt,timer;</div><div class="code_line">type</div><div class="code_line">TElem=integer;</div><div class="code_line">TFile=file of TElem;</div><div class="code_line">Link=^ListElem;</div><div class="code_line">ListElem=record</div><div class="code_line">&nbsp;&nbsp; Data:TElem;</div><div class="code_line">&nbsp;&nbsp; next:Link;</div><div class="code_line">end;</div><div class="code_line">L1_List=object</div><div class="code_line">&nbsp;&nbsp;private</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf:Link;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Temp:Link;</div><div class="code_line">&nbsp;&nbsp; &nbsp;//err_code:word; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;public</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CreateList;//создание списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;constructor CopyList(var List:L1_List);//копирование</div><div class="code_line">&nbsp;&nbsp; &nbsp;destructor Destroy_List;//удаление с очисткой памяти</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ClearList;//очистка текущуго списка</div><div class="code_line">&nbsp;&nbsp; &nbsp;function IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutTempForvard;//вправо</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure InBegin;//в начало</div><div class="code_line">&nbsp;&nbsp; &nbsp;//function IsTempLast:boolean;</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure PutElem(var x:TElem);//вставка элемента за указатель</div><div class="code_line">&nbsp;&nbsp; // procedure GetElem(var x:TElem);//</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure LookElem(var x:TElem);//посмотреть элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure ChangeElem(var x:TElem);//изменить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure DelElem(var x:TElem);//удалить элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp;//procedure GetError;</div><div class="code_line">&nbsp;&nbsp; // procedure MaskError(eror:word);</div><div class="code_line">&nbsp;&nbsp; // procedure ClearMaskErr;</div><div class="code_line">end;</div><div class="code_line">implementation</div><div class="code_line">//********************************</div><div class="code_line">constructor L1_List.CreateList;//</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;new(buf);</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf^.next:=buf;</div><div class="code_line">&nbsp;&nbsp; &nbsp;temp:=buf;</div><div class="code_line">&nbsp;end;</div><div class="code_line">//****************************************</div><div class="code_line">Destructor L1_List.Destroy_List;//</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; while temp&#60;&#62;NIL do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf:=temp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; temp:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; dispose(buf);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; dispose(temp);</div><div class="code_line">&nbsp;&nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//***************************************</div><div class="code_line">procedure L1_List.InBegin;//в начало </div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; Temp:=buf^.next;</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//****************************************</div><div class="code_line">procedure L1_List.PutElem(var x:TElem);//добавить элемент после указателя</div><div class="code_line">var</div><div class="code_line">&nbsp;NewEl:Link;</div><div class="code_line">&nbsp;&nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; new(NewEl);</div><div class="code_line">&nbsp;&nbsp; &nbsp; NewEl^.data:=x;// записываем в него данные</div><div class="code_line">&nbsp;&nbsp; &nbsp; {Если список был пустой, то головой списка становится p}</div><div class="code_line">&nbsp;&nbsp; &nbsp; if buf^.next=NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; NewEl^.next:= nil;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Buf:=NewEl;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NewEl^.next:=Temp^.next;{ в новом элементе делаем ссылку</div><div class="code_line">на следующий элемент, который был до вставки}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Temp^.next:=NewEl;{в текущем элементе делаем ссылку на новый} &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; buf:=Temp^.next;// текущим становится новый элемент</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.PutTempForvard;//двигаем указатель вправо</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;NIL then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; temp:=temp^.next</div><div class="code_line">&nbsp;&nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.DelElem(var x:TElem); &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp; p,p1:Link;//p1 - предыдущий элемент </div><div class="code_line">&nbsp;&nbsp; power:boolean; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if buf^.next&#60;&#62;nil then p:=buf^.next</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while true do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.data = x then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; power:= true;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p^.next = nil then break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1:= p;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= p^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if power then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if p = buf then // если удаляется первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:= buf^.next; // запоминаем ссылку на следующий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(buf); // удаляем первый элемент списка</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;buf:= p; // головой списка становится p</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin // если удаляется не первый элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p1^.next:= p^.next; { в предыдущем элементе заменяем</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ссылку на следующий элемент после удаляемого }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(p);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp:= p1; // текущим делаем предыдущий элемент</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; &nbsp; &nbsp;</div><div class="code_line">//********************************************</div><div class="code_line">constructor L1_List.CopyList(var List:L1_List);</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">//********************************************</div><div class="code_line">procedure L1_List.ClearList;//очистить текущий список</div><div class="code_line">&nbsp;&nbsp;var</div><div class="code_line">&nbsp;&nbsp;tmp:Link; </div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;tmp:=temp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while tmp &#60;&#62; NIL do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;buf:=tmp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmp:=tmp^.next;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dispose(buf);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Dispose(tmp);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">//***********************************************</div><div class="code_line">function L1_List.IsEmptyList:boolean;//пустой ли список</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next = NIL then IsEmptyList:=false</div><div class="code_line">&nbsp;&nbsp; &nbsp;else IsEmptyList:=true;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.ChangeElem(var x:TElem);//изменение элемента за указателем</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then temp^.data:=x;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">procedure L1_List.LookElem(var x:TElem);//посмотреть элемент после указателя</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if temp^.next&#60;&#62;nil then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>kotmatroskin55</author>
        <category>Pascal</category>
      </item>
	
      </channel>
      </rss>
	