讨论 / 为什么总是会连着输出两个负号?
波莱罗 2011-09-08 21:39:00
点我顶贴 收藏 删除
为什么总是会连着输出两个负号?

Program syw0017;

var n,i:integer; a:array[1..200]of integer;

begin

read(n);

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

for i:=0 to n do

begin

if (a[i]=0) then continue;

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

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

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

if abs(a[i])>1 then write(a[i],'x');

if (i<n) then write ('^',n-i);

if (i=n) then write(a[i]);

end;

end.

#1 Conon@2011-09-08 21:39:00
回复 删除
语句

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

a[i]为负数 输出就是 -1 -2 之类的

查看更多回复
提交回复