讨论 / pascal语言题解
lzsyxxyjl 2015-08-05 09:22:33
点我顶贴 收藏 删除
program y_poly;

var n,i:integer;

a:array[0..100] of integer;

f:boolean;

begin

readln(n);

f:=true;

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

for i:=n downto 1 do

if a[i]<>0 then

begin

if (a[i]>0) and (f=false) then write('+');

if a[i]<0 then write('-');

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

if i<>1 then write('x^',i)

else write('x');

f:=false;

end;

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

else if a[0]<0 then write(a[0]);

readln;

readln;

end.

查看更多回复
提交回复