| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这么简单的都WA哪里错了?
var
map:array[1..10,1..10] of char;
way:array[1..10,1..10] of boolean;
step:array[1..10,1..10] of integer;
n,m,g,i,j,l,x,y:integer;
begin
readln(n,m,g);
while (n<>0)or(m<>0)or(g<>0) do
begin
fillchar(map,sizeof(map),0);
for i:=1 to n do
begin
for j:=1 to m do read(map[i,j]);
readln;
end;
fillchar(way,sizeof(way),false);
fillchar(step,sizeof(step),0);
l:=0;
x:=1;
y:=g;
way[x,y]:=true;
repeat
inc(l);
case map[x,y] of
'N':dec(x);
'S':inc(x);
'W':dec(y);
'E':inc(y);
end;
if way[x,y] then
begin
writeln(step[x,y],' step(s) before a loop of ',l-step[x,y],' step(s)');
break;
end;
if (x=0)or(y=0) then
begin
writeln(l,' step(s) to exit');
break;
end;
step[x,y]:=l;
way[x,y]:=true;
until false;
readln(n,m,g);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator