Надосоставить схему алгоритма и программу для вычисления значенийфункции y для заданных значений переменной x и постоянных а, в, h.1. y = xsinx/cosx; a = -1.6, b = 1.6, h = 0.22. y = tgx2 + ctgx2; a = -2, b = 2, h=0.53. y = ln(x2 -9)/x; a = -6, b = 6, h = 14. y = xln(cosx); a = -3, b = 3, h = 0.35. y = tgx/x; a = -2, b = 2, h = 0.26. y = sinx/(x-5); a = -6, b = 6, h = 0.57. y = x/(1-cosx); a = -4, b = 4, h = 0.58. y = 1/xtg(x/2); a = -3, b = 3, h = 0.59. y = 1/(x2 -3); a = -4, b = 4, h = 0.510. y = 1/ln(x2/8); a = -3, b = 3, h = 0.611. y = 1/x ctg(x/3); a = -4, b = 4, h = 0.512. y = ln(16-x2)/x ex; a = -6, b = 6, h = 0.513. y = x tg x/ lnx; a = -3, b = 3, h = 0.514. y = x2ln|x|/sinx; a = -2, b = 2, h = 0.215. y = x/sinx+ ln(x2 - 4); a = - 6, b = 6, h = 0.516. y = x2cosx/ln(x2-1); a = -2, b = 2, h = 0.117. y = xsinx/ln(x2-9); a = -5, b = 5, h = 0.518. y = x2/(cosx+ln(x2-1)); a = -2, b = 2, h = 0.219. y = (x2+ tgx)/ln(x2-4); a = -4, b = 4, h = 0.820. y = (x2- cosx)/xln(x2-1); a = -2, b = 2, h = 0.2
a: array [,] of integer;
begin
var n := ReadlnInteger('n = ');
var m := ReadlnInteger('m = ');
var rand := ReadlnInteger('Для ручного ввода нажмите 0');
if rand = 0 then begin
a := new integer[m, n];
for var i := 0 to m-1 do
for var j := 0 to n-1 do
a[i, j] := ReadlnInteger('a[' + i + ',' + j + '] = ');
end
else a := MatrixRandom(m, n, 1, 100);
Println(a);
var b := ArrGen(n, x -> 1);
for var i := 0 to m-1 do
for var j := 0 to n-1 do
if j mod 2 = 0 then
b[j] := b[j] * a[i, j];
b.Where((x, i)-> i mod 2 = 0).SortedDescending().Println();
end.
Так как язык не указан, приведу пример на SWI-Prolog.
Код:
read_int(Int) :- read(Int), integer(Int).split_int_by_numbers(0, []) :- !.split_int_by_numbers(N, [Number|Ints]) :- Number is mod(N, 10), RestN is div(N, 10), split_int_by_numbers(RestN, Ints).test_to_div(_, []).test_to_div(N, [Number|Ints]) :- mod(N, Number) =:= 0, test_to_div(N, Ints). test(Int) :- split_int_by_numbers(Int, Numbers), test_to_div(Int, Numbers), write(Int), write(" - Yes!"), nl.test(Int) :- write(Int), write(" - No!"), nl.?- read_int(Int), test(Int).