[ create a new paste ] login | about

Link: http://codepad.org/u6yaYYRm    [ raw code | output | fork ]

hoaithu.melody - C++, pasted on Mar 9:
//AlgebraicExpressionLV1
//cho 1 cay nhi phan, ktra xem cay nay co tinh dc ko
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <conio.h>

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("Testcase.txt", "r", stdin);
	for(test_case = 1; test_case <= 10; ++test_case)
	{
		int i;
		memset(Firstchild, 0, sizeof(int) * 201);
		memset(Secondchild, 0, sizeof(int) * 201);
		memset(Num, 0, sizeof(int) * 201);
		memset(Oper, 0, sizeof(char) * 201);

		cin >> N;
		int max = 0;
		for(i = 0; i < N; i++)
		{
			int addr;
			char buf[200];

			cin >> addr;
			cin >> buf;
			
			if(strcmp(buf,"+") == 0 || strcmp(buf,"-")== 0  || strcmp(buf,"/") == 0 || strcmp(buf,"*")== 0)
			{
				Oper[addr] = buf[0];
				max = addr;
			}
			else
				Num[addr] = atoi(buf);
			
			if(addr*2 <= N)
			{
				cin >> Firstchild[addr];
				if(addr*2 + 1 <= N)
					cin >> Secondchild[addr];
			}
		}
		
		int flag = 1;
		for(i = max; i > 0; i--)
		{
			if(Firstchild[i] == 0 || Secondchild[i] == 0)
			{
				flag = 0;
				break;
			}
		}

		cout << "#" << test_case << " " << flag << endl;
	}

	getch();
	return 0;
}


Output:
1
2
3
4
Line 18: error: conio.h: No such file or directory
In function 'int main(int, char**)':
Line 65: error: 'getch' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: