chỗ a,a,a,...,a sửa thành a0,a1,a2,...,an nhé
Lời giải :
program hotrotinhoc ;
var dathuc,n,x,i : integer ;
begin
write('Nhap gia tri cua n='); readln(n);
dathuc := 0;
for a:= 1 to n do
for x:= 1 to n do dathuc:= dathuc+a*(x*x) ;
write('P(x)=',dathuc);
readln
end.
program luythua;
uses crt;
var i,x,n: integer; P: longint;
A: array [1..100] of integer;
function luythua(x,n: integer) : longint;
var i: integer; T:longint;
begin
T:=1;
for i:= 1 to n do T:=T*x;
luythua :=T;
end;
BEGIN
clrscr;
write ('nhap n = '); readln (n);
for i:= 0 to n do begin write ('A[',i,']='); readln (A[i]); end;
write ('x='); readln (x);
P:=0;
for i:= 0 to n do P:=P+(A[i]*luythua(x,i));
write ('tich la: ',P);
READLN
END.
program luythua;
uses crt;
var i,x,n: integer; P: longint;
A: array [1..100] of integer;
function luythua(x,n: integer) : longint;
var i: integer; T:longint;
begin
T:=1;
for i:= 1 to n do T:=T*x;
luythua :=T;
end;
BEGIN
clrscr;
write ('nhap n = '); readln (n);
for i:= 0 to n do begin write ('A[',i,']='); readln (A[i]); end;
write ('x='); readln (x);
P:=0;
for i:= 0 to n do P:=P+(A[i]*luythua(x,i));
write ('tich la: ',P);
READLN
END.