| ||||||||||
| 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 | |||||||||
3295 Tautolopy WA//为什么这个程序WA
#include<cstdio>
#include<cctype>
int var[6];//p,q,r,s,t
char *head,WFF[105];
bool expr()
{
char c=*head;head++;
if (islower(c))return var[c-'p'];
if (c=='K')
{
bool b=expr();
return b && expr();
}else if (c=='A')
{
bool b=expr();
return b || expr();
}else if (c=='N')
{
return !expr();
}else if (c=='C')
{
bool b=expr();
return !b || expr();
}else if (c=='E')
{
bool b=expr();
return !(b ^ expr());
}
}
int main()
{
while(scanf("%s",WFF)==1 && WFF[0] != '0')
{
bool zero=false,one=false;
for (var[0]=0;var[0]<2;var[0]++)
for (var[1]=0;var[1]<2;var[1]++)
for (var[2]=0;var[2]<2;var[2]++)
for (var[3]=0;var[3]<2;var[3]++)
for (var[4]=0;var[4]<2;var[4]++)
{
head=WFF;
if(expr())one=true;
else zero=true;
}
printf(one && !zero ? "tautology\n":"not\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator