Pagini recente » Cod sursa (job #845769) | Cod sursa (job #2036073) | Cod sursa (job #1292524) | Cod sursa (job #2830761) | Cod sursa (job #2072312)
#include <iostream>
#include <fstream>
using namespace std;
char s[100001], *p, c;
bool v[30];
int n;
ifstream f("bool.in");
ofstream g("bool.out");
bool eval();
bool term();
bool fact();
int main()
{
f.getline(s, 100000);
f>>n;
for (i=1; i<=n; i++)
{ v[c-'A']=!v[c-'A'];
p=s;
g<<eval();
}
}
bool eval()
{
bool r=term();
while (*p=='O' || *(p+1)=='R')
{
p+=3;
r=r || term();
}
}
return r;
}
bool term()
{
bool r=fact();
while (*p=='A' && *p+2=='N')
{
++p; r=!r;
//else {++p; r=r/fact();
}
}
return r;
}
bool fact()
{
bool r=false;
if (*p=='('){p++;
r=eval();
p++;}
else
while (*p>='A' && *p<='Z')
{
//r=r*10+(int)*p-'0';
p++;
}
return r;
}