Tautology(POJ 3295编译原理)
2013-08-07 15:53
399 查看
~题目链接~
http://poj.org/problem?id=3295
输入
结果
1.要把p,q,r,s,t的所有取值都搜索一遍
2.'K' a&b; 'A' a||b; 'N' !a; 'C' !a||b;'E' a==b;
3.如果为永真式,输出tautology;否则 not
http://poj.org/problem?id=3295
输入
ApNp ApNq 0
结果
tautology not
1.要把p,q,r,s,t的所有取值都搜索一遍
2.'K' a&b; 'A' a||b; 'N' !a; 'C' !a||b;'E' a==b;
3.如果为永真式,输出tautology;否则 not
#include<stdio.h> #include<string.h> #include<stdlib.h> int n,flag,p,q,r,s,t; char str[100]; int reach() { n++; switch(str ) { case 'K':return reach()&reach(); case 'A':return reach()|reach(); case 'N':return !reach(); case 'C':return !reach()|reach(); case 'E':return reach()==reach(); case 'p':return p; case 'q':return q; case 'r':return r; case 's':return s; case 't':return t; } } int main() { while(~scanf("%s",str) && str[0]!='0') { flag=0; //32中取值情况 for(p=0; p<2; p++) for(q=0; q<2; q++) for(r=0; r<2; r++) for(s=0; s<2; s++) for(t=0; t<2; t++) { n=-1; if(!reach()) flag=1; } if(flag) printf("not\n"); else printf("tautology\n"); } return 0; }
相关文章推荐
- poj3295--Tautology
- POJ 3295--Tautology
- POJ 3295 *** Tautology
- 构造 + 离散数学、重言式 - POJ 3295 Tautology
- poj 3295 Tautology
- poj 3295——Tautology
- Tautology - poj 3295
- POJ 3295 Tautology
- POJ训练计划3295_Tautology(构造/类栈处理)
- POJ3295--Tautology(模拟)
- POJ-3295-Tautology-2013-12-04 20:44:18
- POJ 3295 Tautology 构造数列及STL中栈的运用
- POJ 3295 Tautology(构造法)
- poj 3295 Tautology && poj 1035 Spell checker 【字典树】
- POJ-3295 Tautology 构造法
- [ACM] POJ 3295 Tautology (构造)
- POJ 3295:Tautology
- POJ-3295-Tautology
- POJ 3295 Tautology 构造 stack
- POJ 3295:Tautology