Pagini recente » Cod sursa (job #2298803) | Cod sursa (job #2265907) | Cod sursa (job #1526405) | Cod sursa (job #482546) | Cod sursa (job #2186431)
#include <fstream>
using namespace std;
ifstream f("bool.in");
ofstream g("bool.out");
int n,nr,i;
char x,s[2000];
bool a[128];
bool E();
bool T()
{
if(s[nr]=='N' && s[nr+1]=='O')
{
nr+=3;
return !T();
}
else if(s[nr]=='T' && s[nr+1]=='R' )
{
nr+=4;
return true;
}
else if(s[nr]=='F' && s[nr+1]=='A')
{
nr+=5;
return false;
}
else if (s[nr]=='(')
{
nr++;
bool t=E();
nr++;
return t;
}
else
{
bool t=a[s[nr]];
nr++;
return t;
}
}
bool F()
{
bool t=T();
while(s[nr]=='A' && s[nr+1]=='N')
{
nr+=3;
t&=T();
}
return t;
}
bool E()
{
bool t=F();
while(s[nr]=='O' && s[nr+1]=='R')
{
nr+=2;
t|=F();
}
return t;
}
int main()
{
f.getline(s,2000);
f>>n;
for(i=0;i<n;i++)
{
f>>x;
a[x]^=1;
nr=0;
g<<E();
}
g<<'\n';
return 0;
}