<?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=53066&amp;view=findpost&amp;p=336905</guid>
        <pubDate>Mon, 12 Apr 2004 16:39:38 +0000</pubDate>
        <title>Форматированный вывод на экран</title>
        <link>https://forum.sources.ru/index.php?showtopic=53066&amp;view=findpost&amp;p=336905</link>
        <description><![CDATA[romtek: <div class='tag-align-center'><strong class='tag-b'><span class='tag-size' data-value='12' style='font-size:12pt;'><span class="tag-color tag-color-named" data-value="blue" style="color: blue">Форматированный вывод на экран</span></span></strong></div><br>
<br>
Чем отличаются <strong class='tag-b'>write</strong> от <strong class='tag-b'>writeln</strong>, и <strong class='tag-b'>read</strong> от <strong class='tag-b'>readln</strong>?<br>
<strong class='tag-b'>ln</strong>-означает, что курсор должен перейти на начало следующей строки.<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">write(&#39;Введите строку: &#39;); readln(str);</div><div class="code_line">write(&#39;Введите число: &#39;); readln(num);</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><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">Введите число: 100</div></ol></div></div></div></div><br>
<br>
<span class='tag-u'>Как красиво вывести данные?</span><br>
 <br>
<strong class='tag-b'>Одномерный массив A (M) целых чисел</strong><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">writeln;</div><div class="code_line">{ Выводит числа с промежутком в 4 позиции один от другого, выравнивая по правому краю }</div><div class="code_line">for i:=1 to M do write (A[i] : 4);</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">&nbsp;-10 &nbsp; 3 &nbsp;14 -87</div></ol></div></div></div></div><br>
<br>
<strong class='tag-b'> Матрица A (MxN) из вещественных чисел</strong><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 arr= array[1..P,1..Q] of real;</div><div class="code_line">procedure ShowMatrix(var A: arr; M,N: integer);</div><div class="code_line">var i,j: word;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; Writeln;</div><div class="code_line">&nbsp;&nbsp; &nbsp; For i:=1 to M do</div><div class="code_line">&nbsp;&nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Writeln; { переход на следующую строку }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for j:=1 to N do Write (A[i,j]:8:2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; end;</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">&nbsp;&nbsp; 29.33 &nbsp; 28.00 &nbsp; 20.67</div><div class="code_line">&nbsp;&nbsp; 23.33 &nbsp; 19.00 &nbsp; 10.33</div></ol></div></div></div></div><br>
<br>
<strong class='tag-b'>Записи, База Данных (БД)</strong><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; TDataBook=record</div><div class="code_line">&nbsp;&nbsp; &nbsp; Name: string[30];</div><div class="code_line">&nbsp;&nbsp; &nbsp; Phone: string[10];</div><div class="code_line">&nbsp;&nbsp; &nbsp; Street: string[30];</div><div class="code_line">&nbsp;&nbsp; &nbsp; Gender: Char; {(M)ale/(F)emale}</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">const Rec=3; { Count of Records }</div><div class="code_line">&nbsp;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; DataBook: TDataBook;</div><div class="code_line">&nbsp;&nbsp; A: Array[1..Rec] of TDataBook;</div><div class="code_line">&nbsp;&nbsp; i: word;</div><div class="code_line">&nbsp;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; With DataBook do</div><div class="code_line">&nbsp;&nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for i:=1 to Rec do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with A[i] do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writeln;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(&#39;Name: &#39;); readln(Name);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(&#39;Phone: &#39;); readln(phone);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(&#39;Street: &#39;); readln(street);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(&#39;Gender [(M)ale/(F)emale]: &#39;); readln(gender);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Writeln;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;writeln (&#39;Name&#39;:30, &#39;Phone&#39;:10, &#39;Street&#39;:30, &#39;Gender&#39;:7);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for i:=1 to Rec do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with A[i] do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writeln (Name:30, Phone:10, Street:30, Gender:2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; writeln(&#39;Press Enter.&#39;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; readln;</div><div class="code_line">end.</div></ol></div></div></div></div><br>
<br>
Дополнительные ссылки:<br>
<a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=43434' target='_blank'>Как вывести Real в понятном виде?</a><br>
<a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=39965' target='_blank'>Как вывести текст (строку) ?</a>]]></description>
        <author>romtek</author>
        <category>Pascal: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	