Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project8;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- System.SysUtils;
- Function Answering( M : integer; N : integer) : integer;
- var
- F: extended;
- begin
- if (M = 0) then
- Answering := N + 1;
- if (M > 0) and (N = 0) then
- Answering := Answering(M - 1, 1)
- else if (M > 0) and ( N > 0) then
- Answering := Answering(M - 1 ,Answering(M, N - 1));
- end;
- Function FindingFile(): integer;
- var
- CorrectFile: Boolean;
- NameOfFile: String;
- Input : TextFile;
- M, N,F : integer;
- begin
- repeat
- Write('Введите путь к файлу, с которого хотите считать информацию :');
- Readln(NameOfFile);
- CorrectFile := True;
- try
- AssignFile(Input, NameOfFile);
- Reset(Input);
- if not eof(Input) then
- begin
- ReadLn(Input, M);
- Read(Input, N);
- CloseFile(Input);
- end
- else
- begin
- WriteLn(' Файл оказался пустым ');
- CloseFile(Input) ;
- end;
- except
- CorrectFile := False;
- Writeln('Не удалось найти файл по такому пути', NameOfFile);
- end;
- until CorrectFile;
- F := Answering(M,N);
- WriteLn(F);
- result := F;
- end;
- Procedure SaveFile(NameOutput : String ; F: integer);
- var
- Output: TextFile;
- begin
- Writeln('Введите путь к файлу для записи : ');
- Readln(NameOutput);
- AssignFile(Output,NameOutput);
- Rewrite(Output);
- WriteLn(Output , 'Ответ :', F);
- CloseFile(Output);
- ReadLn;
- end;
- var
- F , M , N : integer;
- CorrectFile: Boolean;
- NameOfFile: String;
- NameOutput : String;
- begin
- F := FindingFile();
- SaveFile(NameOutput, F);
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement