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 |
为什么RE#include <iostream> #include <stdio.h> #include <stack> using namespace std; bool IsUpper(char ch) { if(ch >= 65 && ch <= 90) return true; return false; } bool Cal(char* str, bool p, bool q, bool r, bool s, bool t) { stack<bool> b; stack<char> c; int i, flag = 0; for(i = 0; str[i] != 0; i++) { if(IsUpper(str[i])) { c.push(str[i]); if(str[i] == 'N') flag = 1; } else { switch(str[i]) { case 'p': b.push(p); break; case 'q': b.push(q); break; case 'r': b.push(r); break; case 's': b.push(s); break; case 't': b.push(t); break; } if(flag) { bool tmp = b.top(); b.pop(); b.push(~tmp); c.pop(); flag = 0; } } } bool x, y; while(!c.empty()) { y = b.top(); b.pop(); x = b.top(); b.pop(); char tmp = c.top(); c.pop(); switch(tmp) { case 'K': b.push(x & y); break; case 'A': b.push(x | y); break; case 'C': b.push(~x | y); break; case 'E': b.push(~(x ^ y)); break; } } return b.top(); } int main() { char str[501]; int p,q,r,s,t,flag; while(scanf("%s", str) && str[0] != '0') { flag = 1; for(p = 0; p < 2 && flag; p++) for(q = 0; q < 2 && flag; q++) for(r = 0; r < 2 && flag; r++) for(s = 0; s < 2 && flag; s++) for(t = 0; t < 2 && flag; t++) if(!Cal(str,p,q,r,s,t)) flag = 0; if(flag) puts("tautology"); else puts("not"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator