洛谷 P1067 多项式输出
模拟,很坑的那种
var i,n:longint; a:array[1..105] of integer; begin readln(n); for i:=1 to n+1 do read(a[i]); if a[1]=-1 then write('-'); if a[1]<-1 then write(a[1]); if (a[1]>1) then write(a[1]); if n=1 then write('x') else write('x^',n); for i:=2 to n do begin if a[i]=0 then continue; if a[i]=1 then write('+') else if a[i]=-1 then write('-') else begin if a[i]>0 then write('+'); write(a[i]); end; if n-i+1=1 then write('x') else write('x^',n-i+1); end; if a[n+1]<>0 then begin if a[n+1]>0 then write('+'); write(a[n+1]); end; end.