Ejemplo n.º 1
0
void addEl(Tree *&tr, char string[], int &count)
{
	if ((string[count] == '(') || (string[count] == ')'))
	{
		addEl(tr, string, ++count);
	}
	else
	{
		if(string[count] != '\0')
		{
			if((string[count] == '+') || (string[count] == '-') || (string[count] == '*') || (string[count] == '/'))
			{
				tr = create(string[count++]);
				addEl(tr->left, string, count);
				addEl(tr->right, string, count);
			}
			else
			{
				tr = create(string[count++]);
			}
		}
		else
			return;
	}
}
Ejemplo n.º 2
0
struct node *addEl(struct node *p, int value) {
	if (p == NULL) {
		p = (struct node *) malloc(sizeof(struct node));
		p->value = value;
		p->next = NULL;
	} else {
		p->next = addEl(p->next, value);
	}

	return p;
}
Ejemplo n.º 3
0
int _tmain(int argc, _TCHAR* argv[])
{
	FILE *file;
	file = fopen(". . ..txt", "r");
	char string[30];
	fgets(string, 30, file);
	fclose(file);

	Tree *tree = NULL;		
	int x = 0;

	addEl(tree, string, x);

	printf("%d", conversion(tree));

	delTree(tree);

	return 0;
}