Pagini recente » Cod sursa (job #3157831) | Cod sursa (job #3281104) | Cod sursa (job #3284576)
#include <fstream>
using namespace std;
ifstream cin("bool.in");
ofstream cout("bool.out");
string s;
int poz;
int v[26];
bool rasp1();
bool rasp2();
bool rasp3(){
bool rasp=0;
if(s[poz]=='('){
poz++;rasp=rasp1();poz++;
}else if(s[poz]=='N' && s[poz+1]=='O'){
poz+=4;rasp=1-rasp3();
}else if(s[poz]=='T' && s[poz+1]=='R'){
poz+=5;rasp=1;
}else if(s[poz]=='F' && s[poz+1]=='A'){
poz+=6;rasp=0;
}else{
rasp=v[s[poz]-'A'];poz+=2;
}
return rasp;
}
bool rasp2(){
bool rasp=rasp3();
while(s[poz]=='A'&& s[poz+1]=='N'){
poz+=4;rasp=rasp&rasp3();
}
return rasp;
}
bool rasp1(){
bool rasp=rasp2();
while(s[poz]=='O'&& s[poz+1]=='R'){poz+=3;rasp=rasp|rasp2();}
return rasp;
}
int main()
{
getline(cin,s);
int i,n;char ch;
cin>>n;
for(i=1;i<=n;i++){
cin>>ch;
v[ch-'A']=1-v[ch-'A'];poz=0;
cout<<rasp1();
}
return 0;
}