NOIP2009T1 多项式输出

 

 

var
    a,i,j,n:longint;
begin
    assign(input,'poly.in'); reset(input);
    assign(output,'poly.out'); rewrite(output);
    readln(n);
    for i:=n downto 0 do
    begin
        read(a);
        if a=0 then continue
        else if a<0 then begin write('-'); a:=-a; end
        else if i<n then write('+');

        if a>1 then write(a);

        if i=1 then write('x')
        else if i>1 then write('x^',i)
        else if a=1 then write(1);
    end;
    writeln;
    close(input); close(output);
end.

 

posted @ 2013-10-26 08:00  qilinart  阅读(173)  评论(0)    收藏  举报