讨论 / 求 大神 , 求 大神。
rose、 2011-07-20 18:20:00
点我顶贴 收藏 删除
我 的 程序 。

program hb;

type data=record

z:string;

z4:string;

t:longint;

end;

var n,i,j,tot,t,tt:longint;

yy:array[1..200]of data;

cl:string;

begin

assign(input,'hb.in');

reset(input);

assign(output,'hb.out');

rewrite(output);

readln(n);

for i:=1 to n do

begin

readln(yy[i].z);

yy[i].z4:=copy(yy[i].z,1,4);

if yy[i].z4='jmp ' then

begin

cl:=copy(yy[i].z,4,length(yy[i].z)-3);

val(cl,yy[i].t);

inc(tt);

end

else yy[i].t:=1;

end;

i:=1;

t:=0;

while i<=n do

begin

if t>tt then

begin

writeln(0);

close(input);

close(output);

halt;

end;

if yy[i].z4='jmp ' then

begin

inc(t);

if i<yy[i].t then

begin

inc(tot);

i:=yy[i].t;

end;

if i=yy[i].t then

begin

writeln(0);

close(input);

close(output);

halt;

end;

end

else

begin

inc(tot);

i:=i+yy[i].t;

end;

end;

writeln(tot);

close(input);

close(output);

end.

有 几组 都 没 过 , 应该 是 判断 死循环 的 时候 有错 。

而且 程序 比较 冗长 ,

求 大神 帮 我 看 哈 。 谢谢 。

查看更多回复
提交回复