| ||||||||||
| 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 | |||||||||
终于AC。。。。。var
i, j, n : integer;
c : char;
st : string;
right, left, res : array[1..3] of string;
function isLight(c : char) : boolean;
var
i : integer;
begin
isLight := false;
i := pos(c, left[1]);
for i := 1 to 3 do begin
if (res[i] = 'even') and ((pos(c, left[i]) > 0) or (pos(c, right[i]) > 0)) then exit;
if (res[i] = 'up') and (pos(c, right[i]) <= 0) then exit;
if (res[i] = 'down') and (pos(c, left[i]) <= 0) then exit;
end;
isLight := true;
end;
function isHeavy(c : char) : boolean;
var
i : integer;
begin
isHeavy := false;
for i := 1 to 3 do begin
if (res[i] = 'even') and ((pos(c, left[i]) > 0) or (pos(c, right[i]) > 0)) then exit;
if (res[i] = 'up') and (pos(c, left[i]) <= 0) then exit;
if (res[i] = 'down') and (pos(c, right[i]) <= 0) then exit;
end;
isHeavy := true;
end;
begin
readln(n);
while (n > 0) do begin
for i := 1 to 3 do begin
readln(st);
j := pos(' ', st);
left[i] := copy(st, 1, j - 1);
delete(st, 1, j);
j := pos(' ', st);
right[i] := copy(st, 1, j - 1);
delete(st, 1 , j);
res[i] := st;
end;
for c := 'A' to 'L' do begin
if (isLight(c)) then begin
writeln(c, ' is the counterfeit coin and it is light.');
break;
end;
if (isHeavy(c)) then begin
writeln(c, ' is the counterfeit coin and it is heavy.');
break;
end;
end;
dec(n);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator