• Составить программу которая будет вычислять значение выражения у = cosx + cosx^2 + cosx^3 + ... + cosx^n, используя процедуру вычисляющую x в n степени

Ответы 1

  • Процедурой:// Возводит действилельное число x в целую степень nProcedure Pow(Const X:real; Const n:integer; Var St:real);Var i:integer;BeginSt:=1;For i:= 1 to n do    St:=St*x;End;Var   x,y,St:real;   n:integer;Beginy:=0;Write('x = ');ReadLn(x);Write('n = ');ReadLn(n);For n:= 1 to n do    Begin    Pow(x,n,St);    y:=y+Cos(St);    End;WriteLn('y = ',y);End.Функцией:// Возводит действилельное число x в целую степень nFunction Pow(Const X:real; Const n:integer):real;Var i:integer;Beginresult:=1;For i:= 1 to n do    result:=result*x;End;Var   x,y:real;   n:integer;Beginy:=0;Write('x = ');ReadLn(x);Write('n = ');ReadLn(n);For n:= 1 to n do    y:=y+Cos(Pow(x,n));WriteLn('y = ',y);End.Циклом:Var   x,y,St:real;   n:integer;Beginy:=0;Write('x = ');ReadLn(x);Write('n = ');ReadLn(n);St:=1;For n:= 1 to n do    Begin    St:=St*x;    y:=y+Cos(St);    End;WriteLn('y = ',y);End.
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years