Pagini recente » Cod sursa (job #2409444) | Cod sursa (job #2255901) | Cod sursa (job #2924842) | Cod sursa (job #2585760) | Cod sursa (job #2186466)
#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()
{
noskipws(f);
f>>s[nr];
while(s[nr]!='\n')
{
nr+=(s[nr]!=' ');
f>>s[nr];
}
skipws(f);
f>>n;
for(i=0;i<n;i++)
{
f>>x;
a[x]^=1;
nr=0;
g<<E();
}
g<<'\n';
return 0;
}