BELOW
ABOVE
RIGHT
LEFT
第1题:
请编写函数fun(),该函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间有若干个空格隔开,一行的开始没有空格。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<string. h>
include<stdio, h>
define N 80
int fun (char *s)
{
}
main ( )
{
char line [N];
int num=0;
printf ("Enter a string: \n ");
gets (line);
num=fun (line);
printf ("The number of word is: %d\n\n ",
num);
}
第2题:
阅读下列函数说明、图和C代码,回答问题
[说明]
在进行文法分析的时候,通常需要检测一个单词是否在我们的单词列表里。为了提高查找和定位的速度,通常都要画出与单词列表所对应的单词查找树。
程序构造一棵二叉排序树,每个节点存储一个单词,按字典序列,较小的在左子树,较大的在右子树。
函数中使用的预定义符号如下:
typedef struct TreeNode{/*二叉排序树节点*/
char *word;
struct TreeNode *left, *right;
}BNODE;
[函数]
int getWord(FILE *fpt, char *word)
/*从文件fpt中读取单词到word中,到达文件结束时返回0*/
{
char c;
c = fgetc(fpt);
if(c == EOF)return 0;
/*跳过单词间的非字母字符*/
while(!(tolower(c) >= 'a' && tolower(c) <= 'z')){
c = fgetc(fpt);
if(c == EOF)return 0;
}
/*不区分大小写*/
while(tolower(c) >= 'a' && tolower(c) <= 'z'){
*word++ = c;
c = fqetc(fpt);
}
*word = '\0';
return 1;
}
void BTree(BNODE **t, char *word)
{
BNODE *ptr, *p;
int compres;
p = NITLL;
(1) ;
while(ptr){
compres = strcmp(word, (2) );
if(!compres){
return;
}else{
(3) ;
ptr = compres > 0 ? ptr->right : ptr->left;
}
}
ptr = (BNODE*)malloc(sizeof ptr);
ptr->left = ptr->right = NULL;
ptr->word = (char*)malloc(strlen(word) + 1);
strcpy(ptr->word, word);
if(p == NULL){
(4) ;
}else if(compres > 0){
p->right = ptr;
}else{
p->left = ptr;
}
}
int main()
{
FILE *fpt;
char word[40];
BNODE *root = NULL;
if((fpt = fopen("text.in", "r")) == NULL){
printf("不能打开文件text.in! \n");
return 1;
}
while(getWord(fpt, word) == 1){
BTree (5) ;
}
fclose(fpt);
return 0;
}
第3题:
A.在"start()"中调用getParameter()函数
B.在"init()"中调用getParameter()函数
C.在"main()"中调用getParameter()函数
D.在"paint()"中调用getParameter()函数
第4题:
通过关键字来指定函数模板的类型参数,有几个类型参数就有几个关键字,它实际表示任何内部类型或用户自定义类型。用来指定函数模板的类型参数的关键字是【 】。
第5题:
第6题:
下面单词中( )能做Word 2003的函数参数
A、BELOW
B、ABOVE
C、RIGHT
D、LEFT
第7题:
此题为判断题(对,错)。
第8题:
A.在“start()”中调用getParameter()函数
B.在“init()”中掉用getParameter()函数
C.在“main()”中调用getParameter()函数
D.在“paint()”中调用getParameter()函数
第9题:
在函数声明中,下面哪项是不必要的( )。
A.函数参数的类型和参数名
B.函数名
C.函数的类型
D.函数体
第10题: