Pagini recente » Cod sursa (job #3270520) | Cod sursa (job #1864647) | Cod sursa (job #1537153) | Cod sursa (job #197531) | Cod sursa (job #2591924)
#include <fstream>
using namespace std;
ifstream f("bool.in");
ofstream g("bool.out");
int n,i;
char s[1005],c,*p;
bool v[27],ev();
bool elem(){
bool b=0;
if(*p=='(') {p++;b=ev();p++;}
else if(*p=='F'&&*(p+1)=='A') {p+=6;b=0;}
else if(*p=='T'&&*(p+1)=='R') {p+=5,b=1;}
else if(*p=='N'&&*(p+1)=='O') {p+=4,b=!elem();}
else {b=v[*p-'A'];p+=2;}
return b;
}
bool nd(){
bool b=elem();
while(*p=='A'&&*(p+1)=='N') p+=4,b=b&elem();
return b;
}
bool ev(){
bool b=nd();
while(*p=='O'&&*(p+1)=='R') p+=3,b=b|nd();
return b;
}
int main(){
f.getline(s,1005);
f>>n;
for(i=1;i<=n;++i){
f>>c;
v[c-'A']=!v[c-'A'];
p=s;
g<<ev();
}
return 0;
}