Practice : Record student registration with ordered binary tree Time and name , and then to name Output Student Registration information in ascending order
Stricmp,strcmpi
Prototype:extern int stricmp (char *s1,char * s2);
Usage:#include <string.h>
Features: Compares strings S1 and S2, but does not differentiate between uppercase and lowercase letters.
Description:strcmpi is a macro definition to stricmp and does not actually provide this function.
When s1<s2 , the return value <0
When s1=s2 , the return value =0
When s1>s2 , the return value >0
I. Modification of CreateNodestructNode * CreateNode (Char*name) {time_t T; TM*Timfo; structNode *p=malloc(sizeof(structnode)); P->pleft=p->pright=NULL; //Copy Namestrcpy (P->name,name);//Get the nameTime (&t); TIMFO= LocalTime (&t);//take current system timenode->stutime.hour=timfo->tm_hour;//whennode->stutime.min=timfo->tm_min;//pointsNode->Stuti Second, modify the AddNodestructNode * AddNode (structNode * Pnode,Char*v) { //situation one pnode==null if(pnode==NULL) { returnCreateNode (v); } //Pnode->data=v if(stricmp (pnode->name,v) = =0) { returnPnode; } //v more than node data if(STRICMP (V,pnode->name) >0) { if(pnode->pright==NULL) {Pnode->pright=CreateNode (v); returnPnode->Pright; }Else returnAddNode (PNODE->PRIGHT,V);//Recursive invocation } //v less than node data if(STRICMP (V,pnode->name) <0) { if(pnode->pleft==NULL) {Pnode->pleft=CreateNode (v); returnPnode->Pleft; }Else returnAddNode (PNODE->PLEFT,V);//Recursive invocation } returnNULL;} Third, modify the traversalvoidTraversal (structnode*Pnode) { inti; if(pnode->pleft!=NULL) {Traversal (Pnode-pleft); } printf ("%s,",pnode->name); if(pnode->pright!=NULL) {Traversal (Pnode-pright); } }
The application of C + + ordered binary tree