Algebraic Expression Validity Test

#include <iostream> using namespace std; int N; int Firstchild[201], Secondchild[201], Num[201]; char Oper[201]; int main(int argc, char** argv) { int test_case; freopen("input.txt","r",stdin); for(test_case = 1; test_case <= 10; ++test_case) { for(int i = 0; i <= 201;i++) { Firstchild[i] = 0; Secondchild[i] = 0; Num[i] = 0; Oper[i] = 0; } int ans = 1; cin >> N; for(int i = 0; i < N; i++) { int addr; char buf; cin >> addr; cin >> buf; if( buf == '+'|| buf == '-' || buf == '*' || buf == '/' ) Oper[addr] = buf; else Num[addr] = buf -48; if(addr*2 <= N) { cin >> Firstchild[addr]; if(addr*2 + 1 <= N) cin >> Secondchild[addr]; } } for(int i = 1; i<= N; i++) { if( (Num[i] != 0) ) if(Secondchild[i] !=0 || Firstchild[i] != 0) { ans = 0; break; } } cout << "#" << test_case << " " << ans << endl; ///////////////////////////////////////////////////////////////////////////////////////////// /* 이 부분에 여러분의 알고리즘 구현이 들어갑니다. */ ///////////////////////////////////////////////////////////////////////////////////////////// } return 0;//정상종료시 반드시 0을 리턴해야합니다. }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.