Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

终于AC。。。。。

Posted by WindHarry at 2010-04-02 06:23:44 on Problem 1013
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator