Pagini recente » Cod sursa (job #2632639) | Cod sursa (job #1523441) | Cod sursa (job #1323908) | Cod sursa (job #308697) | Cod sursa (job #2637491)
#include <fstream>
using namespace std;
ifstream cin("bool.in") ;
ofstream cout("bool.out") ;
bool orr() ;
bool andd() ;
bool nott() ;
int n ;
char x[1005], *p ;
bool v[27] ;
bool nott()
{
bool aux = 0 ;
if (*p == '(')
p ++, aux = orr(), p ++ ;
else if (*p == 'F' && *(p + 1) == 'A')
p += 6, aux = 0 ;
else if (*p == 'T' && *(p + 1) == 'R')
p += 5, aux = 1 ;
else if (*p == 'N' && *(p + 1) == 'O')
p += 4, aux = !nott() ;
else
aux = v[*p - 'A'], p += 2 ;
return aux ;
}
bool andd()
{
bool aux = nott() ;
while (*p == 'A' && *(p + 1) == 'N')
p += 4, aux &= nott() ;
return aux ;
}
bool orr()
{
bool aux = andd() ;
while (*p == 'O' && *(p + 1) == 'R')
p += 3, aux |= andd() ;
return aux ;
}
int main()
{
int car = 0 ;
cin.getline(x, 1005) ;
cin >> n ;
for (int i = 1 ; i <= n ; i ++)
cin >> car, v[car - 'A'] = !v[car - 'A'], p = x, cout << orr() ;
return 0;
}