| ||||||||||
| 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 | |||||||||
Re:为什么总是WAIn Reply To:为什么总是runtime error Posted by:windy4573 at 2005-11-13 21:05:19 program p1013;
var
ch :array[1..12]of boolean;
st :array[1..3]of string;
temp :string;
n,i,j :integer;
flag :boolean;
o :char;
procedure doit;
var
i,j,k,len,w:integer;
s1,s2,s:string;
procedure search(ss:string;kind:integer);
var
k,len:integer;
begin
k:=1;len:=length(ss);
while k<=len do
begin
if ch[ord(ss[k])-64]<>true
then begin
o:=ss[k];
if ((s='up')and(kind=1))or((s='down')and(kind=2))
then flag:=false
else flag:=true;
exit;
end;
inc(k);
end;
end;
begin
for i:=1 to 2 do
if pos('even',st[i])=0 then
for j:=i+1 to 3 do
if pos('even',st[j])<>0 then
begin
temp:=st[j];st[j]:=st[i];st[i]:=temp;
break;
end;
i:=1;
while i<=3 do
begin
if pos('even',st[i])<>0 then
begin
k:=0;
j:=1;
while k<2 do
begin
if st[i,j]<>' '
then begin
w:=ord(st[i,j])-64;
ch[w]:=true;
end
else inc(k);
inc(j);
end;
end else
begin
s:=st[i];
k:=pos(' ',s);
s1:=copy(st[i],1,k-1);
len:=length(s1);
delete(s,1,k);
k:=pos(' ',s);
s2:=copy(s,1,k-1);
delete(s,1,k);
k:=1;
search(s1,1);
search(s2,2);
end;
inc(i);
end;
end;
begin
readln(n);
repeat
fillchar(ch,sizeof(ch),false);
for i:=1 to 3 do
readln(st[i]);
doit;
write(o,' is the counterfeit coin and it is ');
if flag
then writeln('light.')
else writeln('heavy.');
dec(n);
until n=0;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator