SHARE
TWEET

Untitled

a guest Jan 14th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program true1;
  2. uses crt, addtrue1, truemenu;
  3. var
  4. s:sotrudniki;
  5. h,j: integer;
  6. f:textfile;
  7. num: longint;
  8. begin
  9. assign(f,'sotrudniki.txt');
  10. j:=0;
  11. h:=0;
  12. num:=0;
  13. repeat
  14. truemenu.menu(num);
  15. case num of
  16. 1: readconsol(s);
  17. 2: writeconsol(s,J);
  18. 3: readfromfile(s,h);
  19. 4: writetofile(s,f,h);
  20. 5: search(s,h);
  21. 6: exit;
  22. end;
  23. until num=6;
  24. end.
  25.  
  26. unit addtrue1;
  27. {$mode objfpc}{$H+}
  28. interface
  29. uses
  30. Classes, SysUtils;
  31. const
  32. n=5;
  33. type
  34. sotrudnik = record
  35. fio:string[50];
  36. data:record
  37. day:1..31;
  38. month:1..12;
  39. year:integer;
  40. end;
  41. salary:integer;
  42. end;
  43. sotrudniki=array[1..n] of sotrudnik;
  44.  
  45. procedure readconsol(var s:sotrudniki);
  46. procedure writeconsol(s:sotrudniki;j:integer);
  47. procedure readfromfile(var s:sotrudniki;var h:integer);
  48. procedure writetofile(s:sotrudniki; var f:textfile; h:integer);
  49. procedure search(s:sotrudniki; h:integer);
  50.  
  51. implementation
  52.  
  53. procedure readconsol(var s:sotrudniki);
  54. var j:integer;
  55. begin
  56. for j:=1 to n do
  57. write('Enter FIO: '); readln(s[j].fio);
  58. writeln('Day of starting the work');
  59. write('Enter day: '); readln(s[j].data.day);
  60. write('Enter month: '); readln(s[j].data.month);
  61. write('Enter year: '); readln(s[j].data.year);
  62. write('Enter value of salary: '); readln(s[j].salary);
  63. writeln(j,' records after fill');
  64. writeln('...Press Enter...');
  65. readln;
  66. end;
  67.  
  68. procedure writeconsol(s:sotrudniki; j:integer);
  69. var
  70. i:integer;
  71. begin
  72. for i:=1 to j do
  73. begin
  74. writeln(i,' - ',s[i].fio,' ');
  75. writeln('Day of starting the work');
  76. writeln((s[i].data.day),'.',(s[i].data.month),'.',(s[i].data.year),' - ',s[i].salary);
  77. writeln(' ');
  78. end;
  79. writeln('...Press Enter...');
  80. readln;
  81. end;
  82.  
  83. procedure readfromfile(var s:sotrudniki;var h:integer);
  84. var
  85. f:textfile;
  86. begin
  87. assign(f,'sotrudniki.txt');
  88. reset(f);
  89. h:=0;
  90. while not eof(f) do
  91. begin
  92. inc(h);
  93. readln(f,s[h].fio);
  94. readln(f,s[h].data.day);
  95. readln(f,s[h].data.month);
  96. readln(f,s[h].data.year);
  97. readln(f,s[h].salary);
  98. end;
  99. close(f);
  100. writeln(h,' records read from file');
  101. writeln('...Press Enter...');
  102. readln;
  103. end;
  104.  
  105. procedure writetofile(s:sotrudniki; var f:textfile; h:integer);
  106. var
  107. i:integer;
  108. begin
  109. assign(f,'sotrudniki.txt');
  110. rewrite(f);
  111. for i:= 1 to h do
  112. begin
  113. writeln(f,s[i].fio);
  114. write(f,s[i].data.day);
  115. write(f,s[i].data.month);
  116. write(f,s[i].data.year);
  117. writeln(f,s[i].salary);
  118. end;
  119. close(f);
  120. writeln(h, 'records saved in file');
  121. write('...Press Enter...');
  122. readln;
  123. end;
  124.  
  125. procedure search(s:sotrudniki; h:integer);
  126. var
  127. j,i,a,b:integer;
  128. begin
  129. writeln('Enter value of salary');
  130. write('from: '); readln(a);
  131. write('to: '); readln(b);
  132. writeln('Workers with such salary: ');
  133. for i:=1 to h do
  134. begin
  135. if ((s[i].salary>=a) and (s[i].salary<=b)) then
  136. writeln(i,' ',s[i].fio,' ',' - ',s[i].data.day,'.',s[i].data.month,'.',s[i].data.year,' - ',s[i].salary);
  137. end;
  138. write('...Press Enter...');
  139. readln;
  140. end;
  141. end.
  142.  
  143. unit truemenu;
  144. {$mode objfpc}{$H+}
  145. interface
  146. uses
  147. Classes, SysUtils;
  148. var
  149. m:integer;
  150. procedure
  151. menu(var num:integer);
  152. implementation
  153. uses crt;
  154. procedure menu(var num:integer);
  155. begin
  156. writeln('1. Reading from consol. ');
  157. writeln('4. Writing to consol. ');
  158. writeln('2. Reading from text file. ');
  159. writeln('5. Recording to file. ');
  160. writeln('3. Find workers with some salary. ');
  161. writeln('6. Exit. ');
  162. writeln('Choose the option: ');
  163. repeat
  164. readln(num);
  165. until num in [1..6];
  166. end;
  167. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top