阅读下列程序说明和C程序,将应填入程序中(n)处的字句,写在对应栏内。
【程序说明】
本程序先从文件读人各考生的准考证号(设为整型数)及成绩,并将其存放在一棵检索二叉树上,二叉树结点的健值是成绩,每个结点带一链表,链表结点存放取得该成绩的考生的准考证号。然后,程序按中序遍历检索二叉树,从高分到低分输出结果,使每行输出成绩及其取得成绩的考生的准考证号。
【程序】
include < stdio. h >
typedef struet idnode {
int id;
struct idnode * next;
} ldNode;
typedef struct marknode I
int mark;
ldNode * head;
struct marknode * left, * right;
} MarkNode;
char fname [ ] = "sp07.dat";
main()
{ int id, mark;
MarkNode * root = null;
FILE * fp = fopen(fname," r" );
if(!fp) {
printf("file%s open error, \n" , fname);
exit(0);
}
while (!feop(fp)) {
fscanf(fp," %d%d", &id, &mark);
btree(&root, id, mark);
}
fclose(fp);
print(root);
}
btree(MarkNod * * mpptr, int id, int mark)
{ ldNode * ip;
MarkNode *mp = * mpptr;
if (1) {
if (mark==p->mark) addldNODE ((2), id);
else if (mark >mp -> mark) btree (&top -> left, id, mark);
else btree(&mp-> right, id, mark);
} else
Imp = (marknode * ) malloc(sizeo (marknode) );
mp -> mark = mark;
mp -> left =mp -> right = NULL;
(3)
addldNode(&mp -> head, id);
(4);
}
}
addldNode(ldNode * * ipp, int id)
{ ldNode * ip = * ipp;
if ((5))addldNode ((6)), id;
else {
ip = (ldNode * )malloc(sizeof(ldNode) );
sp - > id = id;
ip -> next = NULL;
(7)
}
}
print(MarkNode * rap)
{ ldNode *ip, *ip0;
if (mp) {
print (mp -> left);
printf(" %6d: \t" ,mp -> mark);
ip = mp -> head;
while(ip) {
printf(" %6d" ,ip -> id);
ip0 =ip;
ip = ip -> next;
free (ip0);
}
printf(" \n" ); printf(mp -> right); free(mp);
}
}