Cod sursa(job #2072312)

Utilizator jumareastefanstefan jumarea jumareastefan Data 21 noiembrie 2017 18:29:05
Problema Bool Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.9 kb
#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;
}