Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Uses crt;
  2.  
  3. type
  4. masType = array[1..10] of string[25];
  5.  
  6.  
  7.  
  8. var
  9. mas:masType;
  10. i:integer;
  11. input,output:text;
  12.  
  13. procedure sortirovka(var mas:masType);
  14. var
  15. i,j,err,year1,k,year2,count:integer;
  16. sex,p : char;
  17. buf:string;
  18.  
  19. begin
  20. i:=1;
  21. count:=1;
  22. while(i<=10) do
  23. begin
  24.  
  25.  
  26. if (mas[i][24]='P') and (mas[i][25]='M') then
  27. begin
  28.  
  29.  
  30. buf := mas[i];
  31. for j:=i downto 2 do
  32. begin
  33.  
  34.  
  35.  
  36.  
  37. mas[j] := mas[j-1];
  38. end;
  39. mas[1] := buf;
  40. inc(count);
  41.  
  42.  
  43. end;
  44.  
  45.  
  46. inc(i);
  47.  
  48.  
  49. end;
  50.  
  51.  
  52.  
  53.  
  54. for i:=1 to count-1 do
  55. begin
  56. for j:= i+1 to count do
  57. begin
  58. val(copy(mas[i],20,4),year1,err);
  59. val(copy(mas[j],20,4),year2,err);
  60. if(year1 < year2) then
  61. begin
  62. buf := mas[i];
  63. mas[i]:= mas[j];
  64. mas[j] := buf;
  65. end;
  66. end;
  67.  
  68. end;
  69.  
  70. end;
  71.  
  72.  
  73. procedure scan(var f:text;var mas:masType;i:integer);
  74. begin
  75. assign(input,'DAN1.txt');
  76. reset(input);
  77.  
  78. if(i = 1) then
  79. begin
  80.  
  81. end;
  82.  
  83. if(i < 11) then
  84. begin
  85. readln(f,mas[i]);
  86. scan(f,mas,i+1);
  87. end;
  88. if(i = 11) then
  89. close(f);
  90.  
  91. end;
  92.  
  93. procedure writetofile(var f:text;var mas:masType;i:integer);
  94. begin
  95.  
  96. if(i = 1) then
  97. begin
  98. assign(f,'output.txt');
  99. rewrite(f);
  100. end;
  101.  
  102. if(i < 11) then
  103. begin
  104. writeln(f,mas[i]);
  105. writetofile(f,mas,i+1);
  106. end;
  107.  
  108. if(i = 11) then
  109. close(f);
  110.  
  111. end;
  112.  
  113. procedure print (mas:masType;n:integer;i:integer);
  114. begin
  115. if i<n+1 then
  116. begin
  117. writeln (mas[i]);
  118. print (mas,n,i+1);
  119. end;
  120. end;
  121.  
  122. procedure appendtofile (var f:text; mas:masType; i:integer);
  123. begin
  124. if(i = 1) then
  125. begin
  126. assign(f,'output.txt');
  127. append(f);
  128. writeln(f);
  129. end;
  130. if(i < 4) then
  131. begin
  132. writeln(f,mas[i]);
  133. appendtofile(f,mas,i+1);
  134. end;
  135. if(i = 4) then
  136. close(f);
  137.  
  138. end;
  139.  
  140. begin
  141.  
  142. scan(input,mas,1);
  143.  
  144. writetofile(output,mas,1);
  145.  
  146. print(mas,10,1);
  147.  
  148. sortirovka(mas);
  149.  
  150. writeln;
  151.  
  152. print (mas,10,1);
  153.  
  154. writeln;
  155.  
  156. appendtofile(output,mas,1);
  157.  
  158. print(mas,3,1);
  159.  
  160.  
  161. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement