codeblocks per se does not go wrong, because codeblocks is not a compiler and for this it has nothing to do with your code / your compiled program...
I don't think that in so simple code a compiler bug triggers so i think your code is wrong on one point... I made a quick look,
but i didn't find anything critical (beside that you are not deleting Q after a new call)... One thing i can think of is, that cin reads some garbage from the input buffer...
you can try cpp check to analyze your code:
http://cppcheck.sourceforge.net/i have to admit, that your code is not easy to read and to understand...
void creat(List &T,int e) //build the tree
{
if(!T)
{
LNode *S;
S=new LNode;
S->data=e;
S->lchild=S->rchild=NULL;
T=S;
}
else if(e>T->data)creat(T->rchild,e);
else if(e<T->data)creat(T->lchild,e);
}
You assign T a new allocated List, but what happens with the old List??? This is for example a memory leak you should avoid. And i think the whole code is full with this... If your code works, it is luck or tolerance of your OS or compiler, but at one point it will blow up... The consequence is (or better can be) that your program works under debug mode but not in release...
sry i can't help more, but this is now out of the scope of this forum, as you don't have a problem with codeblocks, but with the underlying compiler...