please take a look at this
P(x) = Pn*xn + Pn-1*Xn-1 + ... + P0,(polynomial)
P0, P1, ..., Pn is given. find P(x+1)-P(x).(n ≤ 10)
print P0, P1, ..., Pn(P(x+1)-P(x))
here is the code in pascal
var n,i,k:longint;
p,a:array[0..10] of double;
c:array[0..10;0..10] of longint;
s:double;
begin
n:=-1;
while not eoln do
begin
inc(n);
read(p[n]);
end;
for i:=0 to n do
c[i,0]:=1;
for i:=0 to n do
c[i,i]:=1;
for i:=2 to n dofor k:=1 to i-1 do
c[i,k]:=c[i-1,k-1]+c[i-1,k];
fillchar(a,sizeof(a),0);
for k:=0 to n do
begin
for i:=0 to k do
begin
a[i]:=a[i]+p[k]*c[k,i];
end;
end;
for i:=0 to n-2 do
write((a[i]-p[i]):0:1,' ');
writeln((a[n-1]-p[n-1]):0:1);
end.
wow...
try using the # button to the right of where you post
put the code between (code) and (/code).(except those are [ and ])
That way we can at least see some indenting.
It hurts my eyes just looking at those for loops