Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uses crt;
- type
- masType = array[1..10] of string[25];
- var
- mas:masType;
- i:integer;
- input,output:text;
- procedure sortirovka(var mas:masType);
- var
- i,j,err,year1,k,year2,count:integer;
- sex,p : char;
- buf:string;
- begin
- i:=1;
- count:=1;
- while(i<=10) do
- begin
- if (mas[i][24]='P') and (mas[i][25]='M') then
- begin
- buf := mas[i];
- for j:=i downto 2 do
- begin
- mas[j] := mas[j-1];
- end;
- mas[1] := buf;
- inc(count);
- end;
- inc(i);
- end;
- for i:=1 to count-1 do
- begin
- for j:= i+1 to count do
- begin
- val(copy(mas[i],20,4),year1,err);
- val(copy(mas[j],20,4),year2,err);
- if(year1 < year2) then
- begin
- buf := mas[i];
- mas[i]:= mas[j];
- mas[j] := buf;
- end;
- end;
- end;
- end;
- procedure scan(var f:text;var mas:masType;i:integer);
- begin
- assign(input,'DAN1.txt');
- reset(input);
- if(i = 1) then
- begin
- end;
- if(i < 11) then
- begin
- readln(f,mas[i]);
- scan(f,mas,i+1);
- end;
- if(i = 11) then
- close(f);
- end;
- procedure writetofile(var f:text;var mas:masType;i:integer);
- begin
- if(i = 1) then
- begin
- assign(f,'output.txt');
- rewrite(f);
- end;
- if(i < 11) then
- begin
- writeln(f,mas[i]);
- writetofile(f,mas,i+1);
- end;
- if(i = 11) then
- close(f);
- end;
- procedure print (mas:masType;n:integer;i:integer);
- begin
- if i<n+1 then
- begin
- writeln (mas[i]);
- print (mas,n,i+1);
- end;
- end;
- procedure appendtofile (var f:text; mas:masType; i:integer);
- begin
- if(i = 1) then
- begin
- assign(f,'output.txt');
- append(f);
- writeln(f);
- end;
- if(i < 4) then
- begin
- writeln(f,mas[i]);
- appendtofile(f,mas,i+1);
- end;
- if(i = 4) then
- close(f);
- end;
- begin
- scan(input,mas,1);
- writetofile(output,mas,1);
- print(mas,10,1);
- sortirovka(mas);
- writeln;
- print (mas,10,1);
- writeln;
- appendtofile(output,mas,1);
- print(mas,3,1);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement