Advertisement
gguuppyy

АИСД, 1.3

Mar 15th, 2024
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. program lab13;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils, windows;
  7.  
  8. type
  9. Num = record
  10. N: integer;
  11. Name: string;
  12. LastName: string;
  13. Number: string;
  14. Patronoic: string;
  15. end;
  16.  
  17. LElem = ^Elem;
  18.  
  19. Elem = record
  20. Data: Num;
  21. Next: LElem;
  22. end;
  23.  
  24. var
  25. First: LElem;
  26. LastName, Number: string;
  27. Sort: integer;
  28. Flag: boolean;
  29. isexist: boolean;
  30.  
  31. procedure FindByLastName(X: LElem; LastName: string);
  32. var
  33. Count: integer;
  34. begin
  35. Count := 0;
  36. while X <> nil do
  37. begin
  38. if X^.Data.LastName = LastName then
  39. begin
  40. Write(X^.Data.Name: 10, ' ');
  41. Write(X^.Data.LastName: 15, ' ');
  42. Write(X^.Data.Patronoic: 15, ' ');
  43. WriteLn(X^.Data.Number: 17);
  44. Inc(Count);
  45. end;
  46. X := X^.Next;
  47. end;
  48. if Count = 0 then
  49. WriteLn('??????? ?? ??????????!');
  50.  
  51. end;
  52.  
  53. procedure FindByNumber(X: LElem; Number: string);
  54. var
  55. Count: integer;
  56. IsExist: boolean;
  57. begin
  58. Count := 0;
  59. while X <> nil do
  60. begin
  61. IsExist := True;
  62. if X^.Data.Number = Number then
  63. begin
  64. Write(X^.Data.Name: 10, ' ');
  65. Write(X^.Data.LastName: 15, ' ');
  66. Write(X^.Data.Patronoic: 15, ' ');
  67. WriteLn(X^.Data.Number: 17);
  68. Inc(Count);
  69.  
  70. end;
  71. X := X^.Next;
  72. end;
  73. if Count = 0 then
  74. begin
  75. IsExist := False;
  76. WriteLn('??????? ?? ??????????!');
  77. end;
  78. end;
  79.  
  80. procedure Input(var X: integer);
  81. var
  82. Error: integer;
  83. Sus: string;
  84. begin
  85.  
  86. repeat
  87. ReadLn(Sus);
  88. Val(Sus, X, Error);
  89. if (Error <> 0) or (Length(Sus) <> 7) then
  90. WriteLn('??????!');
  91. until (Error = 0) and (Length(Sus) = 7);
  92.  
  93. end;
  94.  
  95. procedure Make(X: LElem);
  96. var
  97. Y: LElem;
  98. Number, N: integer;
  99. Name, LastName, Patronoic: string;
  100. Change: string;
  101. begin
  102. Change := '??';
  103. N := 1;
  104. while (Change <> '???') do
  105. begin
  106.  
  107. Write('??????? ???: ');
  108. ReadLn(Name);
  109. Write('??????? ???????: ');
  110. ReadLn(LastName);
  111. Write('??????? ????????: ');
  112. ReadLn(Patronoic);
  113. Write('??????? ?????????? ?????: ');
  114. Input(Number);
  115.  
  116. X^.Data.Number := '+37544' + IntToStr(Number);
  117.  
  118. X^.Data.Name := Name;
  119. X^.Data.LastName := LastName;
  120. X^.Data.Patronoic := Patronoic;
  121. X^.Data.N := N;
  122. Inc(N);
  123. Y := X;
  124. New(X);
  125.  
  126. Y^.Next := X;
  127. Write('?????? ???????? ??? ?????? ????????? (??/???) ');
  128. ReadLn(Change);
  129. end;
  130. Y^.Next := nil;
  131.  
  132. end;
  133.  
  134. procedure Show(X: LElem);
  135. begin
  136.  
  137. while (X <> nil) do
  138. begin
  139. Write(X^.Data.Name: 10, ' ');
  140. Write(X^.Data.LastName: 15, ' ');
  141. Write(X^.Data.Patronoic: 15, ' ');
  142. WriteLn(X^.Data.Number: 17);
  143. X := X^.Next;
  144. end;
  145. end;
  146.  
  147. procedure SortNumber(Y: LElem; Sort: integer);
  148. var
  149. Len, I, J: integer;
  150. X: LElem;
  151. Tmps: Num;
  152. Flag: boolean;
  153. begin
  154. X := Y;
  155. Len := 0;
  156. while X <> nil do
  157. begin
  158. Inc(Len);
  159. X := X^.Next;
  160. end;
  161.  
  162. for I := 1 to Len do
  163. begin
  164. X := Y;
  165. for J := 1 to Len - I do
  166. begin
  167. Flag := False;
  168. case Sort of
  169. 1:
  170. if X^.Data.Name > X^.Next^.Data.Name then
  171. Flag := True;
  172. 2:
  173. if X^.Data.LastName > X^.Next^.Data.LastName then
  174. Flag := True;
  175. 3:
  176. if X^.Data.Patronoic > X^.Next^.Data.Patronoic then
  177. Flag := True;
  178. end;
  179.  
  180. if Flag then
  181. begin
  182. Tmps := X^.Data;
  183. X^.Data := X^.Next^.Data;
  184. X^.Next^.Data := Tmps;
  185. end;
  186. X := X^.Next;
  187. end;
  188. end;
  189. end;
  190.  
  191. begin
  192. SetConsoleCP(1251);
  193. SetConsoleOutputCP(1251);
  194. New(First);
  195. Make(First);
  196. WriteLn;
  197. WriteLn('??????????? ??: 1 - ?????, 2 - ???????, 3 - ????????');
  198. Flag := False;
  199. repeat
  200. ReadLn(Sort);
  201. if (Sort in [1, 2, 3]) then
  202. Flag := True;
  203. until Flag;
  204.  
  205. SortNumber(First, Sort);
  206.  
  207. WriteLn;
  208. Show(First);
  209. WriteLn;
  210. WriteLn('??????? ???????, ????? ????? ?????????? ?????');
  211. ReadLn(LastName);
  212. WriteLn;
  213. FindByLastName(First, LastName);
  214. WriteLn;
  215. WriteLn('??????? ?????????? ?????, ????? ????? ???????');
  216. repeat
  217. ReadLn(Number);
  218. WriteLn;
  219. FindByNumber(First, Number);
  220. until isexist;
  221. Dispose(First);
  222.  
  223. Sleep(500000);
  224. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement