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

|| 与 | int 与 bool

Posted by ctgu2012111243 at 2016-07-19 17:52:03 on Problem 3295
RT 正确的代码将t1,t2改成了int就WA,或者将||改成|也WA,求解。。。。
#include <stdio.h>
#include <string.h>

char data[10005];
int value;
int position = 0;
int getValue()
{
	switch(data[position++])
	{
		bool t1,t2;
		case 'p': return (value & (1 << 0));
		case 'q': return (value & (1 << 1));
		case 'r': return (value & (1 << 2));
		case 's': return (value & (1 << 3));
		case 't': return (value & (1 << 4));
		
		case 'N': return !getValue();
		case 'K': t1 = getValue(); t2 = getValue(); return t1 & t2;
    	case 'A': t1 = getValue(); t2 = getValue(); return t1 | t2;
    	case 'C': t1 = getValue(); t2 = getValue(); return (!t1 | t2);
    	case 'E': t1 = getValue(); t2 = getValue(); return (!(t1^t2));
	}
}
int main()
{
	while(scanf("%s", data) != EOF)
	{
		if(strcmp(data, "0") == 0)
		{
			break;
		}
		for(value = 0; value < (1 << 5); value++)
		{
			position = 0;
			if(getValue() == 0) { printf("not\n"); break; }		
		}
		if(value >= (1 << 5)) printf("tautology\n");
	}
	return 0;
}

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