TABLEE.PAS 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. Uses Crt;
  2. Var
  3. i,j, Top,Bottom,Left,Right : longint;
  4. const
  5. f : array [1..7] of Real =
  6. (130.8, 146.8, 164.8, 174.6, 196.0, 220.0, 246.9);
  7. {-----------------------------------------------------------}
  8. Function Strin (i:longint) : byte;
  9. Var strng : string[20];
  10. Begin
  11. str(i, strng);
  12. strin := Length(strng) + 1;
  13. End;{Strin}
  14. {-----------------------------------------------------------}
  15. Procedure Nota(a:real);
  16. Begin
  17. sound(Round(a));
  18. delay(2500);
  19. Nosound
  20. End; {Nota}
  21. {-----------------------------------------------------------}
  22. Procedure PlayMus;
  23. Begin
  24. nota(f[1]);
  25. nota(f[3]);
  26. nota(f[5]);
  27. nota(f[5]);
  28. nota(f[3]);
  29. nota(f[5]);
  30. nota(f[3]);
  31. nota(f[5]);
  32. nota(f[1]);
  33. nota(f[3]);
  34. nota(f[1]);
  35. nota(f[3]);
  36. nota(f[5]);
  37. nota(f[5]);
  38. nota(f[4]);
  39. nota(f[5]);
  40. nota(f[4]);
  41. nota(f[5]);
  42. nota(f[7]);
  43. nota(f[4]);
  44. nota(f[1]);
  45. nota(f[3]);
  46. nota(f[5]);
  47. nota(f[5]);
  48. nota(f[3]);
  49. nota(f[5]);
  50. nota(f[3]);
  51. nota(f[5]);
  52. nota(f[1]);
  53. nota(f[3]);
  54. nota(f[1]);
  55. nota(f[3]);
  56. nota(f[1]);
  57. nota(f[1]);
  58. nota(f[3]);
  59. nota(f[5]);
  60. nota(f[3]);
  61. nota(f[4]);
  62. nota(f[4]);
  63. nota(f[5]);
  64. nota(f[7]);
  65. nota(f[4]);
  66. nota(f[7]);
  67. nota(f[4]);
  68. nota(f[7]);
  69. nota(f[7]);
  70. nota(f[2]);
  71. nota(f[6]);
  72. nota(f[6]);
  73. nota(f[4]);
  74. nota(f[6]);
  75. nota(f[4]);
  76. nota(f[6]);
  77. nota(f[7]);
  78. nota(f[4]);
  79. End; {PlayMus}
  80. {------------------------------------------------------------------}
  81. Procedure DrawTable(l,r,t,b: longint);
  82. Var a : longint;
  83. Const
  84. lg = LightGray;
  85. Begin
  86. TextColor(cyan);
  87. GotoXY(32,2);
  88. Write('Таблица умножения ');
  89. TextColor(LightMagenta);
  90. For a := 39-((abs(l-r)+1)* round(strin(r*b)/2 )) to
  91. (abs(l-r) +1) * strin(r*b) + (38 - (abs(l-r) * round(strin(r*b)/2))) do
  92. Begin
  93. GotoXY(a, 14 - (abs(t-b)+1) div 2 );
  94. Write('═');
  95. GotoXY(a, (15-(abs(t-b)+1) div 2 ) + (abs(t-b)+1));
  96. Write('═');
  97. end;
  98. Write('╝');
  99. GotoXY(WhereX-1, WhereY - 1 - (abs(t-b)+1));
  100. Write('╗');
  101. TextColor(green);
  102. For a := l to r do
  103. begin
  104. GotoXY(37-((abs(l-r)+1)*round(strin(r*b) / 2)) + (a-l+1) * strin(r*b),
  105. 13 - (abs(t-b)+1) div 2);
  106. Write(a);
  107. end;
  108. For a := t to b do
  109. Begin
  110. GotoXY(36-(abs(l-r)+1)*round(strin(r*b)/2), (14 - (abs(t-b)+1) div 2 ) + a-t+1);
  111. If a < 10 then
  112. Begin
  113. TextColor(green);
  114. Write (a);
  115. TextColor(13);
  116. Write(' ║');
  117. end
  118. else begin
  119. TextColor(green);
  120. Write(a);
  121. TextColor(13);
  122. Write(' ║');
  123. end;
  124. GotoXY(WhereX-1, WhereY+1);
  125. Write('╚');
  126. if (strin(r*b) mod 2) = 0 then
  127. begin
  128. GotoXY((41-((abs(l-r)+1)*round(strin(r*b)/2)))+(abs(l-r)+1)*
  129. strin(r*b),(14 - (abs(t-b)+1) div 2) + a - t +1);
  130. Write('║');
  131. end
  132. else
  133. begin
  134. GotoXY((41-((abs(l-r)+1)*round(strin(r*b)/2)))+(abs(l-r)+1)*
  135. strin(r*b) + 1,(14 - (abs(t-b)+1) div 2) + a - t +1);
  136. Write('║');
  137. end;
  138. end;
  139. GotoXY(39-((abs(l-r)+1)*round(strin(r*b) / 2 )), 14 - (abs(t-b)+1) div 2);
  140. Write('╔')
  141. end; {DrawTable}
  142. {----------------------------------------------------------}
  143. Begin
  144. Clrscr;
  145. TextMode(CO80);
  146. TextColor(LightGray);
  147. Writeln('Введите числа до которых строить таблицу, разница между которыми ');
  148. Writeln('меньше 18 и произведение наибольших чисел меньше 1000 ');
  149. Write('в формате: левое правое верхнее нижнее (1 10 2 15): ');
  150. Read(Left, Right, Top , Bottom);
  151. While (abs(left-right) > 17) or (abs(top-bottom) > 17) or
  152. ((abs(left-right) * strin(right*bottom)) > 70 ) do
  153. begin
  154. Write('Попробуйте снова ');
  155. Read(Left, Right, Top , Bottom);
  156. end;
  157. Clrscr;
  158. DrawTable(Left, Right, Top , Bottom);
  159. TextColor(yellow);
  160. For i := top to bottom do
  161. begin
  162. for j := left to right do
  163. begin
  164. GotoXY((37-(abs(left-right)+1)*round(strin(right*bottom) / 2)+
  165. (J-left+1)*strin(right*bottom)), (14-(abs(top-bottom)+1)div 2)+
  166. i-top+1);
  167. Write(I*J);
  168. end;
  169. end;
  170. GotoXY(30,24);
  171. {PlayMus;}
  172. TextColor(red);
  173. Write('... Press any key ... ');
  174. TextColor(lightgray);
  175. ReadKey
  176. End.