Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- MAX = 100;
- type mas = array [1..MAX] of real;
- var
- N, epsL, err : integer;
- x, resS, resY : mas;
- eps : real;
- f : text;
- fName, epsS : string;
- function ryad (x, eps : real) : real;
- var
- a, b, c, Sum : real;
- i : integer;
- begin
- Sum := 0;
- i := 0;
- a := Cos (i * x);
- b := 1;
- repeat
- inc (i);
- a := cos (i * x);
- b := b * i;
- c := a / b;
- Sum := Sum + c;
- until c < eps;
- ryad := Sum;
- end;
- procedure input;
- var
- name : string;
- begin
- write ('Введите имя файла для записи или нажмите Enter: ');
- readln(name);
- if name = ''
- then
- fName := 'Отчет.txt'
- else
- fname := name+'.txt';
- writeln('Запись отчета в файл: ', fName);
- assign (f, fName);
- rewrite (f);
- write ('Введите N : ');
- readln (N);
- write ('Введите точность : ');
- readln (epsS);
- Val (epsS, eps, err);
- epsL := epsS.Length-2;
- end;
- procedure inputX (N : integer);
- var
- i : integer;
- begin
- writeln('Вводите значения x только из промежутка [0.1 ; 1]');
- for i := 1 to N do
- begin
- write ('x[', i,'] = ');
- readln (x[i]);
- end;
- end;
- function resultS (x : mas; N : integer) : mas;
- var
- i : integer;
- a : mas;
- begin
- for i := 1 to N do
- a[i] := ryad (x[i], eps);
- resultS := a;
- end;
- function resultY (x : mas; N : integer) : mas;
- var
- i : integer;
- a : mas;
- begin
- for i := 1 to N do
- a[i] := exp (cos(x[i])) * cos(sin(x[i]));
- resultY := a;
- end;
- procedure output (x, S, y : mas; N : integer);
- var
- i : integer;
- begin
- writeln(f, ' N | x | S | y ');
- for i := 1 to N do
- begin
- writeln(f, '-----+-----+---------+---------');
- writeln (f, i : 5, '|', x[i] : 5, '|', S[i] : 9 : epsL, '|', y[i] : 9 : epsL);
- end;
- writeln ('Результат записан в файл: ', fName);
- close (f);
- writeln ('Работа программы успешно завершена');
- end;
- begin
- input;
- inputX (N);
- ResS := resultS (x, N);
- ResY := resultY (x, N);
- output (x, ResS, ResY, N);
- end.
Advertisement
Add Comment
Please, Sign In to add comment