Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project23;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- System.SysUtils;
- Type
- TArr = set of byte ;
- procedure FindingFile( var X : TArr);
- var
- CorrectFile: Boolean;
- NameOfFile : String;
- Input : TextFile;
- i, n: byte ;
- Reader : array of integer;
- begin
- repeat
- Write('Введите путь к файлу, с которого хотите считать информацию :');
- Readln(NameOfFile);
- CorrectFile := True;
- try
- AssignFile(Input, NameOfFile);
- Reset(Input);
- if not eof(Input) then
- begin
- ReadLn(Input, n);
- SetLength(Reader , n);
- for i := 0 to n-1 do
- begin
- Read(Input,Reader[i]);
- Include( X, Reader[i]);
- end;
- CloseFile(Input);
- end
- else
- begin
- WriteLn(' Файл оказался пустым ');
- CloseFile(Input) ;
- end;
- except
- CorrectFile := False;
- Writeln('Не удалось найти файл по такому пути', NameOfFile);
- end;
- until CorrectFile;
- end;
- function Union( var X1, X2 : TArr): TArr;
- var
- Y , X: TArr ;
- begin
- Y := X1 + X2;
- Union := Y;
- end;
- function EvenElements(var Y : TArr) : TArr;
- var
- Y1 : TArr;
- i : integer;
- begin
- Y1 := [];
- for i := 0 to 255 do
- begin
- if (i in Y) then
- begin
- if (i mod 2 = 0) then
- Y1 := Y1 + [i] ;
- end;
- end;
- EvenElements := Y1;
- end;
- procedure SaveFile(NameOutput : String ; var Y1: TArr );
- var
- Output: TextFile;
- i : integer ;
- begin
- Writeln('Введите путь к файлу для записи : ');
- Readln(NameOutput);
- AssignFile(Output,NameOutput);
- Rewrite(Output);
- for i := 0 to 255 do
- begin
- if i in Y1 then
- Write( Output, i , ' ');
- end;
- WriteLn(Output);
- CloseFile(Output);
- end;
- var
- Y1 , X1 , X2 , Y : TArr;
- NameOutput : String;
- begin
- FindingFile(X1);
- FindingFile(X2);
- Y := Union (X1, X2);
- Y1 := EvenElements(Y);
- SaveFile(NameOutput, Y1);
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement