program ttdd8;
var s:array[1..200] of string;
code,n,i,sum:integer;
s0,ss:string;
f:array[1..200] of boolean;
begin
readln(n);
for i:=1 to n do
readln(s[i]);
i:=1;
fillchar(f,sizeof(f),false);
repeat
if f[i] then begin write(’0’); halt; end
else f[i]:=true;
ss:=copy(s[i],1,4);
if ss=’jmp ’ then
begin
s0:=copy(s[i],5,length(s[i])-4);
val(s0,i,code);
inc(sum);
end
else begin inc(i); inc(sum); end;
until i=n;
write(sum+1);
end.
第7个点我输出200,
第10个点输出20,
但正确结果都是0;
叫了好几遍了,大牛们瞅瞅~~~~
i,n,now,add,l:integer;
pd:array[1..500] of boolean;
a:array[1..500] of string;
ls:string;
begin
readln(n);
for i:=1 to n do readln(a[i]);
fillchar(pd,sizeof(pd),true);
now:=1;
while now<=n do
begin
if pd[now] then
begin
ls:=copy(a[now],1,4);
if ls<>’jmp ’ then
begin
pd[now]:=false;
inc(now);
inc(add);
end;
if ls=’jmp ’ then
begin
pd[now]:=false;
inc(add);
l:=length(a[now]);
val(copy(a[now],5,l),now);
end;
end;
if not(pd[now]) then
begin
writeln(0);
halt;
end;
end;
writeln(add);
end.