讨论 / 终于ac了
niyinchen 2015-02-10 22:33:05
点我顶贴 收藏 删除
var n,f,i:longint;a:array[-1..100000]of longint;

begin

readln(n);f:=n;

for i:=n downto 0 do read(a[i]);

while(a[f]=0)and(f>=0)do dec(f);

if f<0 then begin writeln(0);halt;end;

if f=0 then begin writeln(a[0]);halt;end;

if a[f]=1 then write('x^',f);

if a[f]=-1 then write('-x^',f);

if(a[f]<>1)and(a[f]<>-1)then

begin

if f>1 then

write(a[f],'x^',f)

else write(a[f],'x');

end;

for i:=f-1 downto 2 do

if a[i]<>0 then

begin

if a[i]>0 then write('+');

if a[i]<>1 then

begin

if a[i]<>-1 then write(a[i]);

if a[i]=-1 then write('-');

end;

write('x^',i);

end;

if f-1>=1 then

if a[1]<>0 then

begin

if a[1]=1 then write('+x');

if a[1]=-1 then write('-x');

if(a[1]<>1)and(a[1]>0)then write('+');

if(a[1]<>1)and(a[1]<>-1)then write(a[1],'x');

end;

if f-1>=0 then

if a[0]<>0 then

begin

if a[0]>0 then write('+');

writeln(a[0]);

end;

end.

查看更多回复
提交回复