阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。
【说明】
下面的程序构造一棵以二叉链表为存储结构的二叉树算法。
【函数】
BTCHINALR *createbt ( BTCHINALR *bt )
{
BTCHINALR *q;
struct node1 *s [30];
int j,i;
char x;
printf ( "i,x =" ); scanf ( "%d,%c",&i,&x );
while (i!=0 && x!='$')
{ q = ( BTCHINALR* malloc ( sizeof ( BTCHINALR )); //生成一个结点
(1);
q->1child = NULL;
q->rchild = NULL;
(2);
if((3);)
{j=i/2 //j为i的双亲结点
if(i%2==0
(4) //i为j的左孩子
else
(5) //i为j的右孩子
}
printf ( "i,x =" ); scanf ( "%d,%c",&i,&x ); }
return s[1]
}
第1题:
阅读以下说明和C语言函数,将应填入(n)处的语句写在对应栏内。
【说明】
下面的程序构造一棵以二叉链表为存储结构的二叉树。
【函数】
BitTree *createbt(BitTree *bt)
{
BitTree *q;
struct node *s[30];
int j,i;
char x;
printf("i,x=");
scant("%d,%c",&i,&x);
while(i!=0 && x!='$')
{
q=(BitTree *}malloc(sizeof(BitTree));//生成一个结点
(1);
q->lchild=NULL;
q->rchild=NULL;
(2) ;
if ((3))
{
j=i/2; // j为i的双亲结点
if(i%2==0)
(4); //i为j的左孩子
else
(5); //i为j的右孩子
}
printf("i,x=");
scanf("%d,%c",&i,&x);
}
return s[i];
}
第2题:
●试题二
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
该程序运行后,输出下面的数字金字塔
【程序】
include<stdio.h>
main ()
{char max,next;
int i;
for(max=′1′;max<=′9′;max++)
{for(i=1;i<=20- (1) ;++i)
printf(" ");
for(next= (2) ;next<= (3) ;next++)
printf("%c",next);
for(next= (4) ;next>= (5) ;next--)
printf("%c",next);
printf("\n");
}
}
第3题:
第4题:
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。
【说明】
阅读下面几段C++程序回答相应问题。
比较下面两段程序的优缺点。
①for (i=0; i<N; i++ )
{
if (condition)
//DoSomething
…
else
//DoOtherthing
…
}
②if (condition) {
for (i =0; i<N; i++ )
//DoSomething
}else {
for (i=0; i <N; i++ )
//DoOtherthing
…
}
第5题:
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。