讨论 / 为什么用字符串作老是超时
okbeng 2008-07-16 04:41:00
点我顶贴 收藏 删除
为什么用字符串作老是超时?

主程序如下:

begin

readln(p1,p2,p3);

readln(sm);

repeat

p:=pos(-,sm);

if p=0 then break;

if p=1 then continue;

if (sm[p-1]>=sm[p+1]) or ((sm[p-1] <=9) and (sm[p+1] >=a)) or ((sm[p-1] >=a) and (sm[p+1] <=9))

then sm[p]:=+ else

ex(p);

until p=0;

repeat

p:=pos(+,sm);

if p>0 then sm[p]:=-;

until p=0;

writeln(sm);

end.

#1 wish@2008-07-16 04:41:00
回复 删除
这题最好扫描一遍直接做

或者边读边做

这样大量地搞 pos 效率说不定有点底 -_-

还有可能是你未贴的 ex 函数的问题

查看更多回复
提交回复