Exemplo n.º 1
0
void node::addChild(node* child)
{
	if (child->isLetterNode())
	{
		letter_node* l=(letter_node*)child;
	#ifdef BINARY_SEARCH
		Ptr<letter_node> p1 (l);
		QVector<Ptr<letter_node> >::iterator i = qLowerBound(letter_children->begin(),letter_children->end(), p1);
		if (i==letter_children->end() || *i!=p1)
			letter_children->insert(i, p1);
	#elif defined(HASH_TABLE)
		letter_children->insert(l->getLetter(),l);
	#elif defined(EXTENSIVE_TREE)
		(*letter_children)[getLetterIndex(l->getLetter())]=l;
	#endif
	}
	else
		result_children->append((result_node*)child);
	child->parent=this;
}
Exemplo n.º 2
0
int main()
{
    freopen("keyboard.in", "r", stdin);
    freopen("keyboard.out", "w", stdout);

    while(scanf("%s", input) != EOF)
    {
        int i = 0;
        int j = 0;
        int index = 0;
        for(index=0; index<strlen(input); index++)
        {
            if(getLetterIndex(input[index], &i, &j))
            {
                printf("%c%d", LetterMap[i][0], j+1);
            }
        }
        printf("\n");
    }

    return 0;
}